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
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.bounded_vlbytes'_payload_length
val bounded_vlbytes'_payload_length (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ (let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` (U32.uint_to_t l)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` (U32.uint_to_t l)) pos' == BY.reveal x)) )
val bounded_vlbytes'_payload_length (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ (let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` (U32.uint_to_t l)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` (U32.uint_to_t l)) pos' == BY.reveal x)) )
let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 5, "end_line": 519, "start_col": 0, "start_line": 497 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack FStar.UInt32.t
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Bytes.valid_flbytes_elim", "FStar.UInt32.v", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Low.BoundedInt.read_bounded_integer", "LowParse.Low.Bytes.valid_bounded_vlbytes'_elim", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.op_Addition", "LowParse.Slice.__proj__Mkslice__item__len", "Prims.eq2", "FStar.Bytes.len", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "FStar.Seq.Base.seq", "FStar.Bytes.byte", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "FStar.Bytes.reveal", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Low.Base.Spec.contents" ]
[]
false
true
false
false
false
let bounded_vlbytes'_payload_length (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ (let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` (U32.uint_to_t l)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` (U32.uint_to_t l)) pos' == BY.reveal x)) ) =
let h = HST.get () in [@@ inline_let ]let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@@ inline_let ]let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` (U32.uint_to_t l)) in len
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.ctag_of_effect_annot
val ctag_of_effect_annot : _: Pulse.Syntax.Base.effect_annot -> Pulse.Syntax.Base.ctag
let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 198, "start_col": 0, "start_line": 194 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
_: Pulse.Syntax.Base.effect_annot -> Pulse.Syntax.Base.ctag
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.effect_annot", "Pulse.Syntax.Base.STT", "Pulse.Syntax.Base.STT_Ghost", "Pulse.Syntax.Base.STT_Atomic", "Pulse.Syntax.Base.ctag" ]
[]
false
false
false
true
false
let ctag_of_effect_annot =
function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.accessor_vlbytes_get
val accessor_vlbytes_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i))
val accessor_vlbytes_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i))
let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 47, "end_line": 845, "start_col": 0, "start_line": 840 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> i: FStar.UInt32.t -> LowParse.Low.Base.accessor (LowParse.Low.Bytes.gaccessor_vlbytes_get min max i)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "FStar.UInt32.t", "LowParse.Low.Bytes.accessor_vlbytes'_get", "LowParse.Spec.BoundedInt.log256'", "LowParse.Low.Base.accessor", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "LowParse.Spec.Int.parse_u8_kind", "FStar.UInt8.t", "LowParse.Spec.Int.parse_u8", "LowParse.Low.Bytes.clens_vlbytes_get", "LowParse.Low.Bytes.gaccessor_vlbytes_get" ]
[]
false
false
false
false
false
let accessor_vlbytes_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) =
accessor_vlbytes'_get min max (log256' max) i
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.as_fv
val as_fv : l: FStar.Stubs.Reflection.Types.name -> Pulse.Syntax.Base.fv
let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 83, "start_col": 0, "start_line": 83 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range;
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l: FStar.Stubs.Reflection.Types.name -> Pulse.Syntax.Base.fv
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.name", "Pulse.Syntax.Base.Mkfv", "FStar.Range.range_0", "Pulse.Syntax.Base.fv" ]
[]
false
false
false
true
false
let as_fv l =
{ fv_name = l; fv_range = FStar.Range.range_0 }
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.empty_ascription
val empty_ascription : Pulse.Syntax.Base.comp_ascription
let empty_ascription = { annotated=None; elaborated=None }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 229, "start_col": 0, "start_line": 229 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.comp_ascription
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.Mkcomp_ascription", "FStar.Pervasives.Native.None", "Pulse.Syntax.Base.comp" ]
[]
false
false
false
true
false
let empty_ascription =
{ annotated = None; elaborated = None }
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.valid_exact_all_bytes_elim
val valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos': U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures (let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos'))
val valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos': U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures (let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos'))
let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos))
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 128, "end_line": 416, "start_col": 0, "start_line": 398 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> pos': FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid_exact LowParse.Spec.Bytes.parse_all_bytes h input pos pos') (ensures (let x = LowParse.Low.Base.Spec.contents_exact LowParse.Spec.Bytes.parse_all_bytes h input pos pos' in let length = FStar.UInt32.v pos' - FStar.UInt32.v pos in FStar.Bytes.length x == length /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Bytes.parse_flbytes length) h input pos x pos'))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims._assert", "LowParse.Spec.Base.injective_postcond", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "LowParse.Slice.bytes_of_slice_from", "Prims.unit", "LowParse.Spec.Base.no_lookahead_on", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Base.total_constant_size_parser_kind", "Prims.int", "Prims.op_Subtraction", "FStar.UInt32.v", "LowParse.Low.Base.Spec.contents_exact_eq", "LowParse.Spec.Bytes.parse_all_bytes_kind", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Low.Base.Spec.valid_exact_equiv", "LowParse.Low.Base.Spec.valid_exact", "Prims.squash", "Prims.l_and", "Prims.eq2", "FStar.Bytes.length", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents_exact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos': U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures (let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos')) =
valid_exact_equiv parse_all_bytes h input pos pos'; contents_exact_eq parse_all_bytes h input pos pos'; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos))
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.mk_ppname_no_range
val mk_ppname_no_range (s: string) : ppname
val mk_ppname_no_range (s: string) : ppname
let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 1, "end_line": 60, "start_col": 0, "start_line": 57 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Prims.string -> Pulse.Syntax.Base.ppname
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "Pulse.Syntax.Base.Mkppname", "FStar.Sealed.seal", "FStar.Range.range_0", "Pulse.Syntax.Base.ppname" ]
[]
false
false
false
true
false
let mk_ppname_no_range (s: string) : ppname =
{ name = FStar.Sealed.seal s; range = FStar.Range.range_0 }
false
MerkleTree.New.High.Correct.Base.fst
MerkleTree.New.High.Correct.Base.hash_seq_spec_full_even_next
val hash_seq_spec_full_even_next: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> acc:hash #hsz -> actd:bool -> Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs) (ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
val hash_seq_spec_full_even_next: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> acc:hash #hsz -> actd:bool -> Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs) (ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd = log2c_div j; mt_hashes_next_rel_lift_even #_ #f j hs nhs; if actd then begin MTS.mt_next_rel_upd_even_pad #_ #f (log2c j) (hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc); let n = log2c j in let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in // assume (MTS.mt_next_rel #_ #f n mt nmt); MTS.mt_next_rel_next_lv #_ #f n mt nmt end else MTS.mt_next_rel_next_lv #_ #f (log2c j) (hash_seq_spec_full #_ #f hs acc actd) (hash_seq_spec_full #_ #f nhs acc actd)
{ "file_name": "src/MerkleTree.New.High.Correct.Base.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 48, "end_line": 542, "start_col": 0, "start_line": 527 }
module MerkleTree.New.High.Correct.Base open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High #set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0" /// Sequence helpers val seq_prefix: #a:Type -> s1:S.seq a -> s2:S.seq a{S.length s1 <= S.length s2} -> GTot Type0 let seq_prefix #a s1 s2 = S.equal s1 (S.slice s2 0 (S.length s1)) val seq_head_cons: #a:Type -> x:a -> s:S.seq a -> Lemma (S.head (S.cons x s) == x) [SMTPat (S.cons x s)] let seq_head_cons #a x s = () val seq_tail_cons: #a:Type -> x:a -> s:S.seq a -> Lemma (S.equal (S.tail (S.cons x s)) s) [SMTPat (S.cons x s)] let seq_tail_cons #a x s = () /// Invariants and simulation relation of high-level Merkle tree design // Invariants of internal hashes val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len}) let empty_hashes #hsz len = S.create len S.empty val empty_hashes_head: #hsz:pos -> len:nat{len > 0} -> Lemma (S.head (empty_hashes #hsz len) == S.empty) let empty_hashes_head #_ _ = () val empty_hashes_tail: #hsz:pos -> len:nat{len > 0} -> Lemma (S.equal (S.tail (empty_hashes len)) (empty_hashes #hsz (len - 1))) let empty_hashes_tail #_ _ = () #push-options "--max_fuel 1" val mt_hashes_lth_inv: #hsz:pos -> lv:nat{lv <= 32} -> j:nat{j < pow2 (32 - lv)} -> fhs:hashess #hsz {S.length fhs = 32} -> GTot Type0 (decreases (32 - lv)) let rec mt_hashes_lth_inv #hsz lv j fhs = if lv = 32 then true else (S.length (S.index fhs lv) == j /\ mt_hashes_lth_inv (lv + 1) (j / 2) fhs) val mt_hashes_lth_inv_empty: #hsz:pos -> lv:nat{lv <= 32} -> Lemma (requires True) (ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32)) (decreases (32 - lv)) let rec mt_hashes_lth_inv_empty #hsz lv = if lv = 32 then () else mt_hashes_lth_inv_empty #hsz (lv + 1) val mt_hashes_next_rel: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> GTot Type0 let mt_hashes_next_rel #hsz #f j hs nhs = forall (i:nat{i < j / 2}). S.index nhs i == f (S.index hs (op_Multiply 2 i)) (S.index hs (op_Multiply 2 i + 1)) #pop-options #push-options "--max_fuel 2" val mt_hashes_inv: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv < 32} -> j:nat{j < pow2 (32 - lv)} -> fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} -> GTot Type0 (decreases (32 - lv)) let rec mt_hashes_inv #hsz #f lv j fhs = if lv = 31 then true else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\ mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs) val mt_hashes_inv_empty: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv < 32} -> Lemma (requires True) (ensures (mt_hashes_lth_inv_empty #hsz lv; mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32))) (decreases (32 - lv)) let rec mt_hashes_inv_empty #hsz #f lv = if lv = 31 then () else (mt_hashes_lth_inv_empty #hsz (lv + 1); mt_hashes_inv_empty #_ #f (lv + 1)) val mt_hashes_lth_inv_equiv: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv < 32} -> j:nat{j < pow2 (32 - lv)} -> fhs1:hashess{S.length fhs1 = 32} -> fhs2:hashess{S.length fhs2 = 32} -> Lemma (requires mt_hashes_lth_inv lv j fhs1 /\ S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32)) (ensures mt_hashes_lth_inv #hsz lv j fhs2) (decreases (32 - lv)) let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 = if lv = 31 then () else (assert (S.index fhs1 lv == S.index fhs2 lv); mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2) #pop-options #push-options "--max_fuel 1" val mt_hashes_inv_equiv: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv < 32} -> j:nat{j < pow2 (32 - lv)} -> fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} -> fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} -> Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\ S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32)) (ensures mt_hashes_inv #_ #f lv j fhs2) (decreases (32 - lv)) let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 = if lv = 31 then () else (assert (S.index fhs1 lv == S.index fhs2 lv); assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1)); mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2) val merge_hs: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> hs1:hashess #hsz -> hs2:hashess #hsz {S.length hs1 = S.length hs2} -> GTot (mhs:hashess #hsz {S.length mhs = S.length hs1}) (decreases (S.length hs1)) let rec merge_hs #hsz #f hs1 hs2 = if S.length hs1 = 0 then S.empty else (S.cons (S.append (S.head hs1) (S.head hs2)) (merge_hs #_ #f (S.tail hs1) (S.tail hs2))) val merge_hs_empty: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> len:nat -> Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len)) (empty_hashes #hsz len)) let rec merge_hs_empty #hsz #f len = if len = 0 then () else (empty_hashes_head #hsz len; empty_hashes_tail #hsz len; assert (S.equal (S.append #(hash #hsz) S.empty S.empty) (S.empty #(hash #hsz))); assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len)) (S.cons S.empty (merge_hs #_ #f (empty_hashes (len - 1)) (empty_hashes (len - 1))))); merge_hs_empty #_ #f (len - 1)) val merge_hs_index: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> hs1:hashess -> hs2:hashess{S.length hs1 = S.length hs2} -> i:nat{i < S.length hs1} -> Lemma (requires True) (ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i) (S.append (S.index hs1 i) (S.index hs2 i))) (decreases (S.length hs1)) [SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)] let rec merge_hs_index #hsz #f hs1 hs2 i = if S.length hs1 = 0 then () else if i = 0 then () else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1) val merge_hs_slice_equal: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> ahs1:hashess #hsz -> ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} -> bhs1:hashess #hsz -> bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} -> i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} -> Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\ S.equal (S.slice ahs2 i j) (S.slice bhs2 i j)) (ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j) (S.slice (merge_hs #_ #f bhs1 bhs2) i j)) (decreases (j - i)) let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j = if i = j then () else (assert (S.index ahs1 i == S.index bhs1 i); assert (S.index ahs2 i == S.index bhs2 i); merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j) val merge_hs_upd: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> hs1:hashess #hsz -> hs2:hashess #hsz {S.length hs1 = S.length hs2} -> i:nat{i < S.length hs1} -> v1:hashes #hsz -> v2:hashes #hsz -> Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i)) (S.append v1 v2)) (ensures S.equal (merge_hs #_ #f hs1 hs2) (merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2))) (decreases i) let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 = if S.length hs1 = 0 then () else if i = 0 then () else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2 val mt_olds_inv: #hsz:pos -> lv:nat{lv <= 32} -> i:nat -> olds:hashess #hsz {S.length olds = 32} -> GTot Type0 (decreases (32 - lv)) let rec mt_olds_inv #hsz lv i olds = if lv = 32 then true else (let ofs = offset_of i in S.length (S.index olds lv) == ofs /\ mt_olds_inv #hsz (lv + 1) (i / 2) olds) val mt_olds_inv_equiv: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> i:nat -> olds1:hashess #hsz {S.length olds1 = 32} -> olds2:hashess #hsz {S.length olds2 = 32} -> Lemma (requires mt_olds_inv #hsz lv i olds1 /\ S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32)) (ensures mt_olds_inv #hsz lv i olds2) (decreases (32 - lv)) let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 = if lv = 32 then () else (assert (S.index olds1 lv == S.index olds2 lv); mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2) val mt_olds_hs_lth_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> i:nat -> j:nat{i <= j /\ j < pow2 (32 - lv)} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} -> Lemma (requires True) (ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs)) (decreases (32 - lv)) let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs = if lv = 32 then () else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs) val mt_olds_hs_inv: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv < 32} -> i:nat -> j:nat{i <= j /\ j < pow2 (32 - lv)} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} -> GTot Type0 let mt_olds_hs_inv #hsz #f lv i j olds hs = mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs) // Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and // the spec. While giving such relation, all rightmost hashes are recovered. // Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost // hashes; it has partial rightmost hashes that are enough to calculate // Merkle paths. val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)}) let rec log2 n = if n = 1 then 0 else 1 + log2 (n / 2) val log2_bound: n:nat{n > 0} -> c:nat{n < pow2 c} -> Lemma (log2 n <= c-1) let rec log2_bound n c = if n = 1 then () else log2_bound (n / 2) (c - 1) val log2_div: n:nat{n > 1} -> Lemma (log2 (n / 2) = log2 n - 1) let log2_div n = () val log2c: n:nat -> GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)}) let log2c n = if n = 0 then 0 else (log2 n + 1) val log2c_div: n:nat{n > 0} -> Lemma (log2c (n / 2) = log2c n - 1) let log2c_div n = () val log2c_bound: n:nat -> c:nat{n < pow2 c} -> Lemma (log2c n <= c) let rec log2c_bound n c = if n = 0 then () else log2c_bound (n / 2) (c - 1) val mt_hashes_lth_inv_log: #hsz:pos -> j:nat -> fhs:hashess #hsz {S.length fhs = log2c j} -> GTot Type0 (decreases j) let rec mt_hashes_lth_inv_log #hsz j fhs = if j = 0 then true else (S.length (S.head fhs) == j /\ mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs)) #pop-options #push-options "--max_fuel 2" val mt_hashes_lth_inv_log_next: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 1} -> fhs:hashess #hsz {S.length fhs = log2c j} -> Lemma (requires mt_hashes_lth_inv_log #hsz j fhs) (ensures S.length (S.head fhs) == j /\ S.length (S.head (S.tail fhs)) == j / 2) let mt_hashes_lth_inv_log_next #_ #_ _ _ = () val mt_hashes_inv_log: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} -> GTot Type0 (decreases j) let rec mt_hashes_inv_log #hsz #f j fhs = if j <= 1 then true else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\ mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs)) val mt_hashes_lth_inv_log_converted_: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> j:nat{j < pow2 (32 - lv)} -> fhs:hashess #hsz {S.length fhs = 32} -> Lemma (requires mt_hashes_lth_inv #hsz lv j fhs) (ensures (log2c_bound j (32 - lv); mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j)))) (decreases j) let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs = if j = 0 then () else (log2c_bound (j / 2) (32 - (lv + 1)); mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs) val mt_hashes_lth_inv_log_converted: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j < pow2 32} -> fhs:hashess #hsz {S.length fhs = 32} -> Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs) (ensures (log2c_bound j 32; mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j)))) let mt_hashes_lth_inv_log_converted #_ #f j fhs = mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs val mt_hashes_inv_log_converted_: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> j:nat{j > 0 && j < pow2 (32 - lv)} -> fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} -> Lemma (requires mt_hashes_inv #_ #f lv j fhs) (ensures (log2c_bound j (32 - lv); mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs; mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j)))) (decreases j) #pop-options #push-options "--z3rlimit 100 --initial_fuel 2 --max_fuel 2" let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs = if j = 1 then () else (log2c_bound (j / 2) (32 - (lv + 1)); mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs; mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs) #pop-options val mt_hashes_inv_log_converted: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0 && j < pow2 32} -> fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} -> Lemma (requires mt_hashes_inv #_ #f 0 j fhs) (ensures (log2c_bound j 32; mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs; mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j)))) let mt_hashes_inv_log_converted #_ #f j fhs = mt_hashes_inv_log_converted_ #_ #f 0 j fhs val hash_seq_lift: #hsz:pos -> hs:hashes #hsz -> GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs}) (decreases (S.length hs)) let rec hash_seq_lift #hsz hs = if S.length hs = 0 then S.empty else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs)) #push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2" val hash_seq_lift_index: #hsz:pos -> hs:hashes #hsz -> Lemma (requires True) (ensures forall (i:nat{i < S.length hs}). S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i)) (decreases (S.length hs)) let rec hash_seq_lift_index #hsz hs = if S.length hs = 0 then () else hash_seq_lift_index #hsz (S.tail hs) #pop-options val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len}) let create_pads #hsz len = S.create len (MTS.HPad #hsz) val hash_seq_spec: #hsz:pos -> hs:hashes #hsz {S.length hs > 0} -> GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) let hash_seq_spec #hsz hs = S.append (hash_seq_lift #hsz hs) (create_pads (pow2 (log2c (S.length hs)) - S.length hs)) val hash_seq_spec_index_raw: #hsz:pos -> hs:hashes #hsz {S.length hs > 0} -> i:nat{i < S.length hs} -> Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i)) let hash_seq_spec_index_raw #hsz hs i = hash_seq_lift_index #hsz hs // Now about recovering rightmost hashes #push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1" val mt_hashes_next_rel_lift_even: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 1} -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs) (ensures MTS.mt_next_rel #_ #f (log2c j) (hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)) let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs = hash_seq_lift_index #hsz hs; hash_seq_lift_index #hsz nhs val mt_hashes_next_rel_lift_odd: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 1} -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs) (ensures MTS.mt_next_rel #_ #f (log2c j) (hash_seq_spec #hsz hs) (S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))) let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs = log2c_div j; hash_seq_lift_index #hsz hs; hash_seq_lift_index #hsz nhs val mt_hashes_next_rel_next_even: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 1} -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs) (ensures S.equal (hash_seq_spec #hsz nhs) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs))) let mt_hashes_next_rel_next_even #hsz #f j hs nhs = log2c_div j; mt_hashes_next_rel_lift_even #_ #f j hs nhs; MTS.mt_next_rel_next_lv #_ #f (log2c j) (hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) val hash_seq_spec_full: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz -> actd:bool -> GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) let hash_seq_spec_full #hsz #f hs acc actd = if actd then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc)) else hash_seq_spec #hsz hs val hash_seq_spec_full_index_raw: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} -> Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i == MTS.HRaw (S.index hs i)) let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i = hash_seq_spec_index_raw #hsz hs i val hash_seq_spec_full_case_true: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz -> Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc) let hash_seq_spec_full_case_true #_ #_ _ _ = () val hash_seq_spec_full_even_next: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> hs:hashes #hsz {S.length hs = j} -> nhs:hashes #hsz {S.length nhs = j / 2} -> acc:hash #hsz -> actd:bool -> Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs) (ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) #restart-solver
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Base.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High.Correct", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High.Correct", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 3, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
j: Prims.nat{j > 0} -> hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} -> nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2} -> acc: MerkleTree.New.High.hash -> actd: Prims.bool -> FStar.Pervasives.Lemma (requires j % 2 = 0 /\ MerkleTree.New.High.Correct.Base.mt_hashes_next_rel j hs nhs) (ensures FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.hash_seq_spec_full nhs acc actd) (MerkleTree.Spec.mt_next_lv (MerkleTree.New.High.Correct.Base.hash_seq_spec_full hs acc actd)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "Prims.b2t", "Prims.op_GreaterThan", "MerkleTree.New.High.hashes", "Prims.op_Equality", "FStar.Seq.Base.length", "MerkleTree.New.High.hash", "Prims.int", "Prims.op_Division", "Prims.bool", "MerkleTree.Spec.mt_next_rel_next_lv", "FStar.Seq.Base.seq", "MerkleTree.Spec.padded_hash", "FStar.Seq.Base.upd", "MerkleTree.New.High.Correct.Base.hash_seq_spec", "MerkleTree.Spec.HRaw", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.pow2", "Prims.op_Subtraction", "Prims.op_LessThan", "MerkleTree.New.High.Correct.Base.log2c", "Prims.unit", "MerkleTree.Spec.mt_next_rel_upd_even_pad", "MerkleTree.New.High.Correct.Base.hash_seq_spec_full", "MerkleTree.New.High.Correct.Base.mt_hashes_next_rel_lift_even", "MerkleTree.New.High.Correct.Base.log2c_div" ]
[]
false
false
true
false
false
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j; mt_hashes_next_rel_lift_even #_ #f j hs nhs; if actd then (MTS.mt_next_rel_upd_even_pad #_ #f (log2c j) (hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc); let n = log2c j in let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in MTS.mt_next_rel_next_lv #_ #f n mt nmt) else MTS.mt_next_rel_next_lv #_ #f (log2c j) (hash_seq_spec_full #_ #f hs acc actd) (hash_seq_spec_full #_ #f nhs acc actd)
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.gaccessor_vlbytes'_slice
val gaccessor_vlbytes'_slice (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to))
val gaccessor_vlbytes'_slice (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to))
let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 48, "end_line": 722, "start_col": 0, "start_line": 711 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> from: FStar.UInt32.t -> to: FStar.UInt32.t{FStar.UInt32.v from <= FStar.UInt32.v to /\ FStar.UInt32.v to <= max} -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v to - FStar.UInt32.v from)) (LowParse.Low.Bytes.clens_vlbytes_slice min max from to)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "FStar.UInt32.v", "LowParse.Low.Bytes.gaccessor_vlbytes'_slice_aux", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Base.total_constant_size_parser_kind", "Prims.op_Subtraction", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Bytes.clens_vlbytes_slice", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.l_imp", "LowParse.Low.Base.Spec.gaccessor_pre", "Prims.op_Addition", "FStar.Seq.Base.length", "FStar.Classical.forall_intro", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "FStar.Pervasives.Native.None", "Prims.op_AmpAmp", "Prims.l_or", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Bytes.hide", "FStar.Seq.Base.slice", "Prims.bool", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Low.Base.Spec.gaccessor" ]
[]
false
false
false
false
false
let gaccessor_vlbytes'_slice (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) =
parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x. gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_inv
val tm_inv : p: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term
let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 126, "start_col": 0, "start_line": 126 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.with_range", "Pulse.Syntax.Base.Tm_Inv", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_inv p =
with_range (Tm_Inv p) FStar.Range.range_0
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_vprop
val tm_vprop : Pulse.Syntax.Base.term
let tm_vprop = with_range Tm_VProp FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 125, "start_col": 0, "start_line": 125 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.with_range", "Pulse.Syntax.Base.Tm_VProp", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_vprop =
with_range Tm_VProp FStar.Range.range_0
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.stateful_comp
val stateful_comp : c: Pulse.Syntax.Base.comp -> Prims.bool
let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 396, "start_col": 0, "start_line": 395 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.op_BarBar", "Pulse.Syntax.Base.uu___is_C_ST", "Pulse.Syntax.Base.uu___is_C_STAtomic", "Pulse.Syntax.Base.uu___is_C_STGhost", "Prims.bool" ]
[]
false
false
false
true
false
let stateful_comp (c: comp) =
C_ST? c || C_STAtomic? c || C_STGhost? c
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_emp_inames
val tm_emp_inames : Pulse.Syntax.Base.term
let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 63, "end_line": 129, "start_col": 0, "start_line": 129 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.with_range", "Pulse.Syntax.Base.Tm_EmpInames", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_emp_inames =
with_range Tm_EmpInames FStar.Range.range_0
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.gaccessor_vlbytes_get
val gaccessor_vlbytes_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i))
val gaccessor_vlbytes_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i))
let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 48, "end_line": 837, "start_col": 0, "start_line": 832 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> i: FStar.UInt32.t -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.Bytes.parse_bounded_vlbytes min max) LowParse.Spec.Int.parse_u8 (LowParse.Low.Bytes.clens_vlbytes_get min max i)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "FStar.UInt32.t", "LowParse.Low.Bytes.gaccessor_vlbytes'_get", "LowParse.Spec.BoundedInt.log256'", "LowParse.Low.Base.Spec.gaccessor", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "LowParse.Spec.Int.parse_u8_kind", "FStar.UInt8.t", "LowParse.Spec.Int.parse_u8", "LowParse.Low.Bytes.clens_vlbytes_get" ]
[]
false
false
false
false
false
let gaccessor_vlbytes_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) =
gaccessor_vlbytes'_get min max (log256' max) i
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.gaccessor_vlbytes'_get
val gaccessor_vlbytes'_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i))
val gaccessor_vlbytes'_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i))
let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 37, "end_line": 812, "start_col": 0, "start_line": 803 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> i: FStar.UInt32.t -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) LowParse.Spec.Int.parse_u8 (LowParse.Low.Bytes.clens_vlbytes_get min max i)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "LowParse.Low.Bytes.gaccessor_vlbytes'_get'", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Int.parse_u8_kind", "FStar.UInt8.t", "LowParse.Spec.Int.parse_u8", "LowParse.Low.Bytes.clens_vlbytes_get", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.l_imp", "LowParse.Low.Base.Spec.gaccessor_pre", "Prims.op_Addition", "FStar.UInt32.v", "FStar.Seq.Base.length", "FStar.Classical.forall_intro", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "FStar.Pervasives.Native.None", "Prims.op_AmpAmp", "Prims.l_or", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Bytes.hide", "FStar.Seq.Base.slice", "Prims.bool", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Low.Base.Spec.gaccessor" ]
[]
false
false
false
false
false
let gaccessor_vlbytes'_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) =
Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x. gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_inames
val tm_inames : Pulse.Syntax.Base.term
let tm_inames = with_range Tm_Inames FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 127, "start_col": 0, "start_line": 127 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.with_range", "Pulse.Syntax.Base.Tm_Inames", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_inames =
with_range Tm_Inames FStar.Range.range_0
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.comp_u
val comp_u : c: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.universe
let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 63, "end_line": 410, "start_col": 0, "start_line": 410 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.universe
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.b2t", "Pulse.Syntax.Base.stateful_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__u", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Syntax.Base.universe" ]
[]
false
false
false
false
false
let comp_u (c: comp{stateful_comp c}) =
(st_comp_of_comp c).u
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_star
val tm_star (l r: vprop) : term
val tm_star (l r: vprop) : term
let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 101, "end_line": 132, "start_col": 0, "start_line": 132 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
l: Pulse.Syntax.Base.vprop -> r: Pulse.Syntax.Base.vprop -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.Mkterm", "Pulse.Syntax.Base.Tm_Star", "Pulse.RuntimeUtils.union_ranges", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_star (l r: vprop) : term =
{ t = Tm_Star l r; range = RU.union_ranges l.range r.range }
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.valid_bounded_vlbytes'_elim
val valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (let sz = l in valid (parse_bounded_integer sz) h input pos /\ (let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload)))))
val valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (let sz = l in valid (parse_bounded_integer sz) h input pos /\ (let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload)))))
let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); ()
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 4, "end_line": 450, "start_col": 0, "start_line": 420 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) h input pos) (ensures (let sz = l in LowParse.Low.Base.Spec.valid (LowParse.Spec.BoundedInt.parse_bounded_integer sz) h input pos /\ (let len_payload = LowParse.Low.Base.Spec.contents (LowParse.Spec.BoundedInt.parse_bounded_integer sz) h input pos in min <= FStar.UInt32.v len_payload /\ FStar.UInt32.v len_payload <= max /\ sz + FStar.UInt32.v len_payload == LowParse.Low.Base.Spec.content_length (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) h input pos /\ (let pos_payload = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in let x = LowParse.Low.Base.Spec.contents (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) h input pos in FStar.Bytes.len x == len_payload /\ LowParse.Low.Base.Spec.valid_pos (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l ) h input pos (FStar.UInt32.add pos_payload len_payload) /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v len_payload)) h input pos_payload x (FStar.UInt32.add pos_payload len_payload)))))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Bytes.valid_exact_all_bytes_elim", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Low.Base.Spec.contents", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Low.VLData.valid_bounded_vldata_strong'_elim", "LowParse.Spec.Bytes.parse_all_bytes_kind", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Low.Combinators.valid_synth", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_aux", "LowParse.Spec.Bytes.synth_bounded_vlbytes", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "Prims.squash", "FStar.UInt32.v", "Prims.eq2", "Prims.int", "Prims.op_Addition", "LowParse.Low.Base.Spec.content_length", "FStar.Bytes.len", "LowParse.Low.Base.Spec.valid_pos", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (let sz = l in valid (parse_bounded_integer sz) h input pos /\ (let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload))))) =
valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); ()
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_unknown
val tm_unknown : Pulse.Syntax.Base.term
let tm_unknown = with_range Tm_Unknown FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 130, "start_col": 0, "start_line": 130 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.with_range", "Pulse.Syntax.Base.Tm_Unknown", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_unknown =
with_range Tm_Unknown FStar.Range.range_0
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.accessor_vlbytes'
val accessor_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length)))
val accessor_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length)))
let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 31, "end_line": 671, "start_col": 0, "start_line": 657 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 6, "max_fuel": 2, "max_ifuel": 6, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> length: FStar.UInt32.t -> LowParse.Low.Base.accessor (LowParse.Low.Bytes.gaccessor_vlbytes' min max l (FStar.UInt32.v length))
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "Prims.unit", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Slice.bytes_of_slice_from", "LowParse.Low.Bytes.valid_bounded_vlbytes'_elim", "LowParse.Low.Base.Spec.slice_access_eq", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.UInt32.v", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Bytes.clens_vlbytes", "LowParse.Low.Bytes.gaccessor_vlbytes'", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.accessor" ]
[]
false
false
false
false
false
let accessor_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) =
fun #rrel #rel sl pos -> let h = HST.get () in [@@ inline_let ]let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` (U32.uint_to_t l)
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.comp_pre
val comp_pre : c: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.vprop
let comp_pre (c:comp { stateful_comp c }) = (st_comp_of_comp c).pre
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 417, "start_col": 0, "start_line": 417 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u let universe_of_comp (c:comp_st) = match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c)
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.vprop
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.b2t", "Pulse.Syntax.Base.stateful_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Syntax.Base.vprop" ]
[]
false
false
false
false
false
let comp_pre (c: comp{stateful_comp c}) =
(st_comp_of_comp c).pre
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.comp_post
val comp_post : c: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.vprop
let comp_post (c:comp { stateful_comp c }) = (st_comp_of_comp c).post
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 69, "end_line": 419, "start_col": 0, "start_line": 419 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u let universe_of_comp (c:comp_st) = match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c) let comp_pre (c:comp { stateful_comp c }) = (st_comp_of_comp c).pre
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.vprop
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.b2t", "Pulse.Syntax.Base.stateful_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Syntax.Base.vprop" ]
[]
false
false
false
false
false
let comp_post (c: comp{stateful_comp c}) =
(st_comp_of_comp c).post
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_emp
val tm_emp : Pulse.Syntax.Base.term
let tm_emp = with_range Tm_Emp FStar.Range.range_0
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 128, "start_col": 0, "start_line": 128 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.with_range", "Pulse.Syntax.Base.Tm_Emp", "FStar.Range.range_0" ]
[]
false
false
false
true
false
let tm_emp =
with_range Tm_Emp FStar.Range.range_0
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.get_vlbytes'_contents
val get_vlbytes'_contents (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` (U32.uint_to_t l)) (BY.len x) /\ B.as_seq h b == BY.reveal x))
val get_vlbytes'_contents (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` (U32.uint_to_t l)) (BY.len x) /\ B.as_seq h b == BY.reveal x))
let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 55, "end_line": 566, "start_col": 0, "start_line": 546 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> input: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack (LowStar.Buffer.buffer LowParse.Bytes.byte)
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowStar.Buffer.sub", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.mbuffer", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.UInt32.v", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowStar.Buffer.buffer", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Low.BoundedInt.read_bounded_integer", "LowParse.Low.Bytes.valid_bounded_vlbytes'_elim", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.op_Addition", "FStar.Bytes.length", "LowParse.Slice.__proj__Mkslice__item__len", "Prims.eq2", "LowStar.Buffer.gsub", "FStar.Bytes.len", "FStar.Seq.Base.seq", "FStar.Bytes.byte", "LowStar.Monotonic.Buffer.as_seq", "FStar.Bytes.reveal", "LowParse.Low.Base.Spec.contents" ]
[]
false
true
false
false
false
let get_vlbytes'_contents (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` (U32.uint_to_t l)) (BY.len x) /\ B.as_seq h b == BY.reveal x)) =
let h = HST.get () in [@@ inline_let ]let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@@ inline_let ]let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` (U32.uint_to_t l)) in BF.sub input.base (pos `U32.add` (U32.uint_to_t l)) len
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_exists_sl
val tm_exists_sl (u: universe) (b: binder) (body: vprop) : term
val tm_exists_sl (u: universe) (b: binder) (body: vprop) : term
let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 145, "end_line": 133, "start_col": 0, "start_line": 133 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
u150: Pulse.Syntax.Base.universe -> b: Pulse.Syntax.Base.binder -> body: Pulse.Syntax.Base.vprop -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.Mkterm", "Pulse.Syntax.Base.Tm_ExistsSL", "Pulse.RuntimeUtils.union_ranges", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_exists_sl (u: universe) (b: binder) (body: vprop) : term =
{ t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range }
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.validate_bounded_vlgenbytes
val validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t{U32.v min == vmin}) (vmax: der_length_t{vmax > 0}) (max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk))
val validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t{U32.v min == vmin}) (vmax: der_length_t{vmax > 0}) (max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk))
let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t { U32.v min == vmin } ) (vmax: der_length_t { vmax > 0 }) (max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } ) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) = validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ()) ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) ()
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 992, "start_col": 0, "start_line": 970 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len inline_for_extraction let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "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
vmin: LowParse.Spec.DER.der_length_t -> min: FStar.UInt32.t{FStar.UInt32.v min == vmin} -> vmax: LowParse.Spec.DER.der_length_t{vmax > 0} -> max: FStar.UInt32.t{FStar.UInt32.v max == vmax /\ FStar.UInt32.v min <= FStar.UInt32.v max} -> vk: LowParse.Low.Base.validator pk -> rk: LowParse.Low.Base.leaf_reader pk -> LowParse.Low.Base.validator (LowParse.Spec.Bytes.parse_bounded_vlgenbytes vmin vmax pk)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.DER.der_length_t", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThanOrEqual", "LowParse.Spec.DER.der_length_max", "FStar.UInt32.v", "Prims.op_GreaterThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Low.Base.validator", "LowParse.Low.Base.leaf_reader", "LowParse.Low.Combinators.validate_synth", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.Low.VLGen.validate_bounded_vlgen", "LowParse.Low.Bytes.validate_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes" ]
[]
false
false
false
false
false
let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t{U32.v min == vmin}) (vmax: der_length_t{vmax > 0}) (max: U32.t{U32.v max == vmax /\ U32.v min <= U32.v max}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) =
validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ())) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) ()
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.tm_forall_sl
val tm_forall_sl (u: universe) (b: binder) (body: vprop) : term
val tm_forall_sl (u: universe) (b: binder) (body: vprop) : term
let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 145, "end_line": 134, "start_col": 0, "start_line": 134 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
u156: Pulse.Syntax.Base.universe -> b: Pulse.Syntax.Base.binder -> body: Pulse.Syntax.Base.vprop -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.Mkterm", "Pulse.Syntax.Base.Tm_ForallSL", "Pulse.RuntimeUtils.union_ranges", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Base.term" ]
[]
false
false
false
true
false
let tm_forall_sl (u: universe) (b: binder) (body: vprop) : term =
{ t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range }
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.jump_bounded_vlgenbytes
val jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk))
val jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk))
let jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk)) = jump_synth (jump_bounded_vlgen vmin vmax vk rk serialize_all_bytes ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) ()
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 1012, "start_col": 0, "start_line": 995 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len inline_for_extraction let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len inline_for_extraction let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t { U32.v min == vmin } ) (vmax: der_length_t { vmax > 0 }) (max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } ) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) = validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ()) ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "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
vmin: LowParse.Spec.DER.der_length_t -> vmax: LowParse.Spec.DER.der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296} -> vk: LowParse.Low.Base.jumper pk -> rk: LowParse.Low.Base.leaf_reader pk -> LowParse.Low.Base.jumper (LowParse.Spec.Bytes.parse_bounded_vlgenbytes vmin vmax pk)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.DER.der_length_t", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Low.Base.jumper", "LowParse.Low.Base.leaf_reader", "LowParse.Low.Combinators.jump_synth", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.Low.VLGen.jump_bounded_vlgen", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes" ]
[]
false
false
false
false
false
let jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk)) =
jump_synth (jump_bounded_vlgen vmin vmax vk rk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) ()
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.default_effect_hint
val default_effect_hint:effect_hint
val default_effect_hint:effect_hint
let default_effect_hint : effect_hint = FStar.Sealed.seal None
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 172, "start_col": 0, "start_line": 172 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Pulse.Syntax.Base.effect_hint
Prims.Tot
[ "total" ]
[]
[ "FStar.Sealed.seal", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.ctag", "FStar.Pervasives.Native.None" ]
[]
false
false
false
true
false
let default_effect_hint:effect_hint =
FStar.Sealed.seal None
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.nvar
val nvar : Type0
let nvar = ppname & var
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 425, "start_col": 0, "start_line": 425 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u let universe_of_comp (c:comp_st) = match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c) let comp_pre (c:comp { stateful_comp c }) = (st_comp_of_comp c).pre let comp_post (c:comp { stateful_comp c }) = (st_comp_of_comp c).post let comp_inames (c:comp { C_STAtomic? c }) : term = match c with | C_STAtomic inames _ _ -> inames
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.var" ]
[]
false
false
false
true
true
let nvar =
ppname & var
false
Steel.ST.Array.Util.fsti
Steel.ST.Array.Util.compare
val compare (#a: eqtype) (#p0 #p1: perm) (a0 a1: A.array a) (#s0 #s1: G.erased (Seq.seq a)) (n: US.t{US.v n == A.length a0 /\ A.length a0 == A.length a1}) : ST bool ((A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) (fun _ -> (A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) (requires True) (ensures fun b -> b <==> s0 == s1)
val compare (#a: eqtype) (#p0 #p1: perm) (a0 a1: A.array a) (#s0 #s1: G.erased (Seq.seq a)) (n: US.t{US.v n == A.length a0 /\ A.length a0 == A.length a1}) : ST bool ((A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) (fun _ -> (A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) (requires True) (ensures fun b -> b <==> s0 == s1)
let compare (#a:eqtype) (#p0 #p1:perm) (a0 a1:A.array a) (#s0 #s1:G.erased (Seq.seq a)) (n:US.t{US.v n == A.length a0 /\ A.length a0 == A.length a1}) : ST bool (A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1) (fun _ -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1) (requires True) (ensures fun b -> b <==> s0 == s1) = let b = for_all2 n a0 a1 (fun x y -> x = y) in A.pts_to_length a0 s0; A.pts_to_length a1 s1; assert (b <==> Seq.equal s0 s1); return b
{ "file_name": "lib/steel/Steel.ST.Array.Util.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 113, "start_col": 0, "start_line": 94 }
(* 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. *) module Steel.ST.Array.Util module G = FStar.Ghost module US = FStar.SizeT module A = Steel.ST.Array open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Some utilities for steel arrays /// Create an array whose elements are specified by the input function inline_for_extraction val array_literal (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) : ST (A.array a) emp (fun arr -> A.pts_to arr full_perm (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))) (requires US.v n > 0) (ensures fun arr -> A.length arr == US.v n) /// Check if all the elements of an array satisfy a predicate inline_for_extraction val for_all (#a:Type0) (#perm:perm) (#s:G.erased (Seq.seq a)) (n:US.t) (arr:A.array a) (p:a -> bool) : ST bool (A.pts_to arr perm s) (fun _ -> A.pts_to arr perm s) (requires A.length arr == US.v n) (ensures fun b -> b <==> (forall (i:nat). i < Seq.length s ==> p (Seq.index s i))) /// for_all2, for predicates over elements of two arrays inline_for_extraction val for_all2 (#a #b:Type0) (#p0 #p1:perm) (#s0:G.erased (Seq.seq a)) (#s1:G.erased (Seq.seq b)) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) : ST bool (A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1) (fun _ -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1) (requires A.length a0 == US.v n /\ A.length a0 == A.length a1) (ensures fun b -> b <==> (forall (i:nat). (i < Seq.length s0 /\ i < Seq.length s1) ==> p (Seq.index s0 i) (Seq.index s1 i))) /// An array compare function that uses for_all2 /// to loop over the two arrays and compre their elements
{ "checked_file": "/", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.Util.fsti" }
[ { "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.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
a0: Steel.ST.Array.array a -> a1: Steel.ST.Array.array a -> n: FStar.SizeT.t { FStar.SizeT.v n == Steel.ST.Array.length a0 /\ Steel.ST.Array.length a0 == Steel.ST.Array.length a1 } -> Steel.ST.Effect.ST Prims.bool
Steel.ST.Effect.ST
[]
[]
[ "Prims.eqtype", "Steel.FractionalPermission.perm", "Steel.ST.Array.array", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "FStar.SizeT.t", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.SizeT.v", "Steel.ST.Array.length", "Steel.ST.Util.return", "Prims.bool", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.VStar", "Steel.ST.Array.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.unit", "Prims._assert", "Prims.l_iff", "Prims.b2t", "FStar.Seq.Base.equal", "Steel.ST.Array.pts_to_length", "Steel.ST.Array.Util.for_all2", "Prims.op_Equality", "Steel.Effect.Common.star", "Prims.l_True" ]
[]
false
true
false
false
false
let compare (#a: eqtype) (#p0 #p1: perm) (a0 a1: A.array a) (#s0 #s1: G.erased (Seq.seq a)) (n: US.t{US.v n == A.length a0 /\ A.length a0 == A.length a1}) : ST bool ((A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) (fun _ -> (A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) (requires True) (ensures fun b -> b <==> s0 == s1) =
let b = for_all2 n a0 a1 (fun x y -> x = y) in A.pts_to_length a0 s0; A.pts_to_length a1 s1; assert (b <==> Seq.equal s0 s1); return b
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.ctag_of_comp_st
val ctag_of_comp_st (c: comp_st) : ctag
val ctag_of_comp_st (c: comp_st) : ctag
let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 179, "start_col": 0, "start_line": 175 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c)
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp_st -> Pulse.Syntax.Base.ctag
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp_st", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.STT", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.STT_Atomic", "Pulse.Syntax.Base.STT_Ghost", "Pulse.Syntax.Base.ctag" ]
[]
false
false
false
true
false
let ctag_of_comp_st (c: comp_st) : ctag =
match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.as_binder
val as_binder : t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.binder
let as_binder (t:term) = null_binder t
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 427, "start_col": 0, "start_line": 427 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u let universe_of_comp (c:comp_st) = match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c) let comp_pre (c:comp { stateful_comp c }) = (st_comp_of_comp c).pre let comp_post (c:comp { stateful_comp c }) = (st_comp_of_comp c).post let comp_inames (c:comp { C_STAtomic? c }) : term = match c with | C_STAtomic inames _ _ -> inames let nvar = ppname & var
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.binder
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.null_binder", "Pulse.Syntax.Base.binder" ]
[]
false
false
false
true
false
let as_binder (t: term) =
null_binder t
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.as_effect_hint
val as_effect_hint (c: ctag) : effect_hint
val as_effect_hint (c: ctag) : effect_hint
let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c)
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 70, "end_line": 173, "start_col": 0, "start_line": 173 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.ctag -> Pulse.Syntax.Base.effect_hint
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.ctag", "FStar.Sealed.seal", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.effect_hint" ]
[]
false
false
false
true
false
let as_effect_hint (c: ctag) : effect_hint =
FStar.Sealed.seal (Some c)
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.get_bounded_vlgenbytes_contents
val get_bounded_vlgenbytes_contents (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (jk: jumper pk) (input: slice (BF.trivial_preorder _) (BF.trivial_preorder _)) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in B.modifies B.loc_none h h' /\ U32.v pos1 + BY.length x == U32.v (get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos) /\ b == BF.gsub input.base pos1 (BY.len x) /\ B.as_seq h b == BY.reveal x)))
val get_bounded_vlgenbytes_contents (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (jk: jumper pk) (input: slice (BF.trivial_preorder _) (BF.trivial_preorder _)) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in B.modifies B.loc_none h h' /\ U32.v pos1 + BY.length x == U32.v (get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos) /\ b == BF.gsub input.base pos1 (BY.len x) /\ B.as_seq h b == BY.reveal x)))
let get_bounded_vlgenbytes_contents (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (jk: jumper pk) (input: slice (BF.trivial_preorder _) (BF.trivial_preorder _)) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in B.modifies B.loc_none h h' /\ U32.v pos1 + BY.length x == U32.v (get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos) /\ b == BF.gsub input.base pos1 (BY.len x) /\ B.as_seq h b == BY.reveal x ))) = let len = bounded_vlgenbytes_payload_length vmin vmax rk input pos in let pos1 = jk input pos in BF.sub input.base pos1 len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 1086, "start_col": 0, "start_line": 1064 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len inline_for_extraction let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len inline_for_extraction let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t { U32.v min == vmin } ) (vmax: der_length_t { vmax > 0 }) (max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } ) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) = validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ()) ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk)) = jump_synth (jump_bounded_vlgen vmin vmax vk rk serialize_all_bytes ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x )))) = let h = HST.get () in valid_synth h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes ) (synth_bounded_vlbytes vmin vmax) input pos; valid_bounded_vlgen_elim vmin vmax pk serialize_all_bytes input pos h; let len = rk input pos in let pos1 = Ghost.hide (get_valid_pos pk h input pos) in valid_exact_all_bytes_elim h input (Ghost.reveal pos1) (Ghost.reveal pos1 `U32.add` len); valid_flbytes_elim h (U32.v len) input (Ghost.reveal pos1); len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "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
vmin: LowParse.Spec.DER.der_length_t -> vmax: LowParse.Spec.DER.der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296} -> rk: LowParse.Low.Base.leaf_reader pk -> jk: LowParse.Low.Base.jumper pk -> input: LowParse.Slice.slice (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte) (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte) -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack (LowStar.Buffer.buffer LowParse.Bytes.byte)
FStar.HyperStack.ST.Stack
[]
[]
[ "LowParse.Spec.DER.der_length_t", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Low.Base.leaf_reader", "LowParse.Low.Base.jumper", "LowParse.Slice.slice", "LowStar.Buffer.trivial_preorder", "LowParse.Bytes.byte", "FStar.UInt32.t", "LowStar.Buffer.sub", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.buffer", "LowParse.Low.Bytes.bounded_vlgenbytes_payload_length", "FStar.Monotonic.HyperStack.mem", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.eq2", "Prims.int", "Prims.op_Addition", "FStar.UInt32.v", "FStar.Bytes.length", "LowParse.Low.Base.Spec.get_valid_pos", "LowStar.Buffer.gsub", "FStar.Bytes.len", "FStar.Seq.Base.seq", "FStar.Bytes.byte", "LowStar.Monotonic.Buffer.as_seq", "FStar.Bytes.reveal", "LowParse.Low.Base.Spec.contents" ]
[]
false
true
false
false
false
let get_bounded_vlgenbytes_contents (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (jk: jumper pk) (input: slice (BF.trivial_preorder _) (BF.trivial_preorder _)) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in B.modifies B.loc_none h h' /\ U32.v pos1 + BY.length x == U32.v (get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos) /\ b == BF.gsub input.base pos1 (BY.len x) /\ B.as_seq h b == BY.reveal x))) =
let len = bounded_vlgenbytes_payload_length vmin vmax rk input pos in let pos1 = jk input pos in BF.sub input.base pos1 len
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.gaccessor_vlbytes'_aux
val gaccessor_vlbytes'_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (length: nat{length < 4294967296}) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length))
val gaccessor_vlbytes'_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (length: nat{length < 4294967296}) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length))
let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end)
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 632, "start_col": 0, "start_line": 613 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 6, "max_fuel": 2, "max_ifuel": 6, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> length: Prims.nat{length < 4294967296} -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) (LowParse.Spec.Bytes.parse_flbytes length) (LowParse.Low.Bytes.clens_vlbytes min max length)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Bytes.bytes", "Prims.unit", "FStar.Classical.move_requires", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Bytes.clens_vlbytes", "LowParse.Low.Base.Spec.gaccessor_post", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Spec.Base.parse_strong_prefix", "FStar.Seq.Base.slice", "LowParse.Bytes.byte", "Prims.op_Addition", "FStar.Seq.Base.length", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "Prims.bool", "LowParse.Low.Base.Spec.gaccessor'" ]
[]
false
false
false
false
false
let gaccessor_vlbytes'_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (length: nat{length < 4294967296}) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) =
fun (input: bytes) -> (let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res)
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.effect_annot_of_comp
val effect_annot_of_comp (c: comp_st) : effect_annot
val effect_annot_of_comp (c: comp_st) : effect_annot
let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens }
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 55, "end_line": 192, "start_col": 0, "start_line": 187 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp_st -> Pulse.Syntax.Base.effect_annot
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp_st", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.EffectAnnotSTT", "Pulse.Syntax.Base.EffectAnnotGhost", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.EffectAnnotAtomic", "Pulse.Syntax.Base.Mkeffect_annot__EffectAnnotAtomic__payload", "Pulse.Syntax.Base.effect_annot" ]
[]
false
false
false
true
false
let effect_annot_of_comp (c: comp_st) : effect_annot =
match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic ({ opens = opens })
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.valid_bounded_vlbytes_intro
val valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : Lemma (requires (let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid (parse_flbytes (U32.v len)) h input pos_payload))) (ensures (let sz = log256' max in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len)))
val valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : Lemma (requires (let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid (parse_flbytes (U32.v len)) h input pos_payload))) (ensures (let sz = log256' max in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len)))
let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 68, "end_line": 904, "start_col": 0, "start_line": 881 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> len: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires (let sz = LowParse.Spec.BoundedInt.log256' max in min <= FStar.UInt32.v len /\ FStar.UInt32.v len <= max /\ LowParse.Low.Base.Spec.valid (LowParse.Spec.BoundedInt.parse_bounded_integer sz) h input pos /\ LowParse.Low.Base.Spec.contents (LowParse.Spec.BoundedInt.parse_bounded_integer sz) h input pos == len /\ FStar.UInt32.v pos + sz <= 4294967295 /\ (let pos_payload = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v len)) h input pos_payload))) (ensures (let sz = LowParse.Spec.BoundedInt.log256' max in let pos_payload = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Bytes.parse_bounded_vlbytes min max) h input pos (LowParse.Low.Base.Spec.contents (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v len) ) h input pos_payload) (FStar.UInt32.add pos_payload len)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Bytes.valid_bounded_vlbytes'_intro", "LowParse.Spec.BoundedInt.log256'", "Prims.unit", "FStar.UInt32.v", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "Prims.eq2", "LowParse.Low.Base.Spec.contents", "Prims.op_Addition", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.BoundedInt.integer_size", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : Lemma (requires (let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid (parse_flbytes (U32.v len)) h input pos_payload))) (ensures (let sz = log256' max in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len))) =
valid_bounded_vlbytes'_intro h min max (log256' max) input pos len
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.mk_binder
val mk_binder (s: string) (r: range) (t: term) : binder
val mk_binder (s: string) (r: range) (t: term) : binder
let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 79, "end_line": 362, "start_col": 0, "start_line": 361 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Prims.string -> r: Pulse.Syntax.Base.range -> t: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.binder
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "Pulse.Syntax.Base.range", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.mk_binder_with_attrs", "Pulse.Syntax.Base.mk_ppname", "FStar.Reflection.Typing.seal_pp_name", "Pulse.Syntax.Base.binder_attrs_default", "Pulse.Syntax.Base.binder" ]
[]
false
false
false
true
false
let mk_binder (s: string) (r: range) (t: term) : binder =
mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.with_st_comp
val with_st_comp (c: comp{stateful_comp c}) (s: st_comp) : comp
val with_st_comp (c: comp{stateful_comp c}) (s: st_comp) : comp
let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 408, "start_col": 0, "start_line": 404 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> s: Pulse.Syntax.Base.st_comp -> Pulse.Syntax.Base.comp
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.b2t", "Pulse.Syntax.Base.stateful_comp", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.C_ST", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.C_STAtomic", "Pulse.Syntax.Base.C_STGhost" ]
[]
false
false
false
false
false
let with_st_comp (c: comp{stateful_comp c}) (s: st_comp) : comp =
match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.buffer_equals_bytes
val buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) ))
val buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) ))
let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 5, "end_line": 322, "start_col": 0, "start_line": 264 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
const: FStar.Bytes.bytes -> b: LowStar.Monotonic.Buffer.mbuffer LowParse.Bytes.byte rrel rel -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.Bytes.bytes", "LowStar.Monotonic.Buffer.srel", "LowParse.Bytes.byte", "LowStar.Monotonic.Buffer.mbuffer", "FStar.UInt32.t", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "LowStar.Monotonic.Buffer.index", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.__uint_to_t", "C.Loops.do_while", "Prims.op_Equality", "Prims.op_Negation", "LowStar.Monotonic.Buffer.upd", "FStar.UInt8.t", "FStar.Bytes.get", "FStar.UInt32.add", "FStar.Classical.move_requires", "FStar.Seq.Base.equal", "FStar.Seq.Properties.snoc", "Prims.l_and", "Prims.eq2", "FStar.Seq.Properties.lemma_snoc_inj", "Prims._assert", "FStar.Bytes.byte", "FStar.Seq.Base.slice", "FStar.Bytes.reveal", "FStar.UInt32.v", "LowStar.Monotonic.Buffer.as_seq", "Prims.op_Addition", "FStar.Bytes.index", "FStar.Seq.Base.seq", "LowStar.Monotonic.Buffer.get", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_buffer", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_imp", "FStar.UInt.uint_t", "FStar.UInt32.n", "Prims.l_iff", "FStar.Seq.Base.index", "FStar.HyperStack.ST.get", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.uint_to_t", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "FStar.Bytes.len", "FStar.HyperStack.ST.push_frame", "LowStar.Monotonic.Buffer.live", "FStar.Bytes.length", "LowStar.Monotonic.Buffer.loc_none" ]
[]
false
true
false
false
false
let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) =
let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@@ inline_let ]let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ (let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i)) `Seq.equal` (Seq.slice (BY.reveal const) 0 i))) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else let i' = i `U32.add` 1ul in [@@ inline_let ]let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert ((Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i')) `Seq.equal` (Seq.snoc s1 c1)); assert ((Seq.slice (BY.reveal const) 0 (U32.v i')) `Seq.equal` (Seq.snoc s2 c2)); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res); let res = B.index bres 0ul in HST.pop_frame (); res
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.gaccessor_vlbytes'_slice_aux
val gaccessor_vlbytes'_slice_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to))
val gaccessor_vlbytes'_slice_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to))
let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end)
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 709, "start_col": 0, "start_line": 696 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> from: FStar.UInt32.t -> to: FStar.UInt32.t{FStar.UInt32.v from <= FStar.UInt32.v to /\ FStar.UInt32.v to <= max} -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v to - FStar.UInt32.v from)) (LowParse.Low.Bytes.clens_vlbytes_slice min max from to)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "FStar.UInt32.v", "LowParse.Bytes.bytes", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.op_Addition", "Prims.bool", "Prims.unit", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Low.Base.Spec.gaccessor'", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Base.total_constant_size_parser_kind", "Prims.op_Subtraction", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Bytes.clens_vlbytes_slice" ]
[]
false
false
false
false
false
let gaccessor_vlbytes'_slice_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) =
fun (input: bytes) -> (parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) else (l + U32.v from))
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.mk_binder_ppname
val mk_binder_ppname (binder_ty: term) (binder_ppname: ppname) : binder
val mk_binder_ppname (binder_ty: term) (binder_ppname: ppname) : binder
let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 365, "start_col": 0, "start_line": 364 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
binder_ty: Pulse.Syntax.Base.term -> binder_ppname: Pulse.Syntax.Base.ppname -> Pulse.Syntax.Base.binder
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.mk_binder_with_attrs", "Pulse.Syntax.Base.binder_attrs_default", "Pulse.Syntax.Base.binder" ]
[]
false
false
false
true
false
let mk_binder_ppname (binder_ty: term) (binder_ppname: ppname) : binder =
mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.st_comp_of_comp
val st_comp_of_comp (c: comp{stateful_comp c}) : st_comp
val st_comp_of_comp (c: comp{stateful_comp c}) : st_comp
let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 402, "start_col": 0, "start_line": 398 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp{Pulse.Syntax.Base.stateful_comp c} -> Pulse.Syntax.Base.st_comp
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.b2t", "Pulse.Syntax.Base.stateful_comp", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability" ]
[]
false
false
false
false
false
let st_comp_of_comp (c: comp{stateful_comp c}) : st_comp =
match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.universe_of_comp
val universe_of_comp : c: Pulse.Syntax.Base.comp_st -> FStar.Stubs.Reflection.Types.universe
let universe_of_comp (c:comp_st) = match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c)
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 415, "start_col": 0, "start_line": 412 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp_st -> FStar.Stubs.Reflection.Types.universe
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp_st", "Pulse.Syntax.Base.st_comp", "FStar.Reflection.Typing.u_zero", "Pulse.Syntax.Base.comp", "Pulse.Reflection.Util.u_max_two", "Pulse.Syntax.Base.comp_u", "FStar.Stubs.Reflection.Types.universe" ]
[]
false
false
false
true
false
let universe_of_comp (c: comp_st) =
match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c)
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.comp_res
val comp_res (c: comp) : term
val comp_res (c: comp) : term
let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 393, "start_col": 0, "start_line": 388 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) }
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Pulse.Syntax.Base.observability" ]
[]
false
false
false
true
false
let comp_res (c: comp) : term =
match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.null_binder
val null_binder (t: term) : binder
val null_binder (t: term) : binder
let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 60, "end_line": 359, "start_col": 0, "start_line": 358 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs}
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.binder
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.mk_binder_with_attrs", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Base.binder_attrs_default", "Pulse.Syntax.Base.binder" ]
[]
false
false
false
true
false
let null_binder (t: term) : binder =
mk_binder_with_attrs t ppname_default binder_attrs_default
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.gaccessor_vlbytes'_get'
val gaccessor_vlbytes'_get' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i))
val gaccessor_vlbytes'_get' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i))
let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end)
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 801, "start_col": 0, "start_line": 777 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> i: FStar.UInt32.t -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) LowParse.Spec.Int.parse_u8 (LowParse.Low.Bytes.clens_vlbytes_get min max i)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "LowParse.Bytes.bytes", "Prims.unit", "FStar.Classical.move_requires", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Int.parse_u8_kind", "FStar.UInt8.t", "LowParse.Spec.Int.parse_u8", "LowParse.Low.Bytes.clens_vlbytes_get", "LowParse.Low.Base.Spec.gaccessor_post", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Spec.Base.parse_strong_prefix", "FStar.Seq.Base.slice", "LowParse.Bytes.byte", "Prims.op_Addition", "FStar.UInt32.v", "FStar.Seq.Base.length", "LowParse.Spec.Int.parse_u8_spec'", "Prims._assert", "Prims.eq2", "Prims.int", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.Base.get_parser_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "Prims.bool", "LowParse.Low.Base.Spec.gaccessor'" ]
[]
false
false
false
false
false
let gaccessor_vlbytes'_get' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) =
fun (input: bytes) -> (let res = if Seq.length input <= l + U32.v i then (0) else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res)
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.valid_exact_all_bytes_intro
val valid_exact_all_bytes_intro (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos': U32.t) : Lemma (requires (U32.v pos <= U32.v pos' /\ (let length = U32.v pos' - U32.v pos in valid (parse_flbytes length) h input pos))) (ensures (valid_exact parse_all_bytes h input pos pos'))
val valid_exact_all_bytes_intro (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos': U32.t) : Lemma (requires (U32.v pos <= U32.v pos' /\ (let length = U32.v pos' - U32.v pos in valid (parse_flbytes length) h input pos))) (ensures (valid_exact parse_all_bytes h input pos pos'))
let valid_exact_all_bytes_intro (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires ( U32.v pos <= U32.v pos' /\ ( let length = U32.v pos' - U32.v pos in valid (parse_flbytes length) h input pos ))) (ensures ( valid_exact parse_all_bytes h input pos pos' )) = let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos'
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 52, "end_line": 1108, "start_col": 0, "start_line": 1088 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len inline_for_extraction let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len inline_for_extraction let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t { U32.v min == vmin } ) (vmax: der_length_t { vmax > 0 }) (max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } ) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) = validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ()) ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk)) = jump_synth (jump_bounded_vlgen vmin vmax vk rk serialize_all_bytes ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x )))) = let h = HST.get () in valid_synth h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes ) (synth_bounded_vlbytes vmin vmax) input pos; valid_bounded_vlgen_elim vmin vmax pk serialize_all_bytes input pos h; let len = rk input pos in let pos1 = Ghost.hide (get_valid_pos pk h input pos) in valid_exact_all_bytes_elim h input (Ghost.reveal pos1) (Ghost.reveal pos1 `U32.add` len); valid_flbytes_elim h (U32.v len) input (Ghost.reveal pos1); len inline_for_extraction let get_bounded_vlgenbytes_contents (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (jk: jumper pk) (input: slice (BF.trivial_preorder _) (BF.trivial_preorder _)) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in B.modifies B.loc_none h h' /\ U32.v pos1 + BY.length x == U32.v (get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos) /\ b == BF.gsub input.base pos1 (BY.len x) /\ B.as_seq h b == BY.reveal x ))) = let len = bounded_vlgenbytes_payload_length vmin vmax rk input pos in let pos1 = jk input pos in BF.sub input.base pos1 len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> pos': FStar.UInt32.t -> FStar.Pervasives.Lemma (requires FStar.UInt32.v pos <= FStar.UInt32.v pos' /\ (let length = FStar.UInt32.v pos' - FStar.UInt32.v pos in LowParse.Low.Base.Spec.valid (LowParse.Spec.Bytes.parse_flbytes length) h input pos)) (ensures LowParse.Low.Base.Spec.valid_exact LowParse.Spec.Bytes.parse_all_bytes h input pos pos')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Base.Spec.contents_exact_eq", "LowParse.Spec.Bytes.parse_all_bytes_kind", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "Prims.unit", "LowParse.Low.Base.Spec.valid_exact_equiv", "Prims._assert", "LowParse.Spec.Base.injective_postcond", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "LowParse.Slice.bytes_of_slice_from", "LowParse.Spec.Base.no_lookahead_on", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Base.total_constant_size_parser_kind", "Prims.int", "Prims.op_Subtraction", "FStar.UInt32.v", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Low.Base.Spec.valid", "Prims.squash", "LowParse.Low.Base.Spec.valid_exact", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let valid_exact_all_bytes_intro (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos': U32.t) : Lemma (requires (U32.v pos <= U32.v pos' /\ (let length = U32.v pos' - U32.v pos in valid (parse_flbytes length) h input pos))) (ensures (valid_exact parse_all_bytes h input pos pos')) =
let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); valid_exact_equiv parse_all_bytes h input pos pos'; contents_exact_eq parse_all_bytes h input pos pos'
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.accessor_vlbytes'_get
val accessor_vlbytes'_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i))
val accessor_vlbytes'_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i))
let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 43, "end_line": 828, "start_col": 0, "start_line": 815 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> i: FStar.UInt32.t -> LowParse.Low.Base.accessor (LowParse.Low.Bytes.gaccessor_vlbytes'_get min max l i)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "Prims.unit", "LowParse.Low.Base.Spec.slice_access_eq", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Int.parse_u8_kind", "FStar.UInt8.t", "LowParse.Spec.Int.parse_u8", "LowParse.Low.Bytes.clens_vlbytes_get", "LowParse.Low.Bytes.gaccessor_vlbytes'_get", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Slice.bytes_of_slice_from", "LowParse.Low.Base.Spec.valid_facts", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.accessor" ]
[]
false
false
false
false
false
let accessor_vlbytes'_get (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) =
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in (pos `U32.add` (U32.uint_to_t l)) `U32.add` i
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.finalize_bounded_vlbytes
val finalize_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h)) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos'))
val finalize_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h)) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos'))
let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 63, "end_line": 967, "start_col": 0, "start_line": 945 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> len: FStar.UInt32.t -> FStar.HyperStack.ST.Stack FStar.UInt32.t
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Bytes.finalize_bounded_vlbytes'", "LowParse.Spec.BoundedInt.log256'", "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.live_slice", "FStar.UInt32.v", "Prims.op_Addition", "LowParse.Slice.__proj__Mkslice__item__len", "LowParse.Low.Base.writable", "LowParse.Slice.buffer_srel_of_srel", "LowParse.Slice.__proj__Mkslice__item__base", "LowParse.Spec.BoundedInt.integer_size", "LowStar.Monotonic.Buffer.modifies", "LowParse.Slice.loc_slice_from_to", "Prims.eq2", "Prims.int", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "FStar.Bytes.hide", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "FStar.UInt32.add", "FStar.UInt32.uint_to_t" ]
[]
false
true
false
false
false
let finalize_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h)) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos')) =
finalize_bounded_vlbytes' min max (log256' max) input pos len
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.valid_bounded_vlgenbytes
val valid_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t{vmin <= vmax /\ vmax > 0 /\ vmax < 4294967296}) (#sk: parser_kind) (pk: parser sk (bounded_int32 (vmin) (vmax))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len))) (ensures (let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in let x = BY.hide (bytes_of_slice_from_to h input pos1 (pos1 `U32.add` len)) in valid_content_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos x (pos1 `U32.add` len)))
val valid_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t{vmin <= vmax /\ vmax > 0 /\ vmax < 4294967296}) (#sk: parser_kind) (pk: parser sk (bounded_int32 (vmin) (vmax))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len))) (ensures (let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in let x = BY.hide (bytes_of_slice_from_to h input pos1 (pos1 `U32.add` len)) in valid_content_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos x (pos1 `U32.add` len)))
let valid_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t { vmin <= vmax /\ vmax > 0 /\ vmax < 4294967296 } ) (#sk: parser_kind) (pk: parser sk (bounded_int32 (vmin) (vmax))) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires ( valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len ))) (ensures ( let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in let x = BY.hide (bytes_of_slice_from_to h input pos1 (pos1 `U32.add` len)) in valid_content_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos x (pos1 `U32.add` len) )) = let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in valid_flbytes_intro h (U32.v len) input pos1; let pos' = pos1 `U32.add` len in valid_exact_all_bytes_intro h input pos1 pos' ; valid_exact_all_bytes_elim h input pos1 pos' ; valid_bounded_vlgen vmin vmax pk serialize_all_bytes input pos h; valid_synth_intro h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes ) (synth_bounded_vlbytes vmin vmax) input pos
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 7, "end_line": 1150, "start_col": 0, "start_line": 1110 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len inline_for_extraction let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len inline_for_extraction let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t { U32.v min == vmin } ) (vmax: der_length_t { vmax > 0 }) (max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } ) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) = validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ()) ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk)) = jump_synth (jump_bounded_vlgen vmin vmax vk rk serialize_all_bytes ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x )))) = let h = HST.get () in valid_synth h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes ) (synth_bounded_vlbytes vmin vmax) input pos; valid_bounded_vlgen_elim vmin vmax pk serialize_all_bytes input pos h; let len = rk input pos in let pos1 = Ghost.hide (get_valid_pos pk h input pos) in valid_exact_all_bytes_elim h input (Ghost.reveal pos1) (Ghost.reveal pos1 `U32.add` len); valid_flbytes_elim h (U32.v len) input (Ghost.reveal pos1); len inline_for_extraction let get_bounded_vlgenbytes_contents (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (jk: jumper pk) (input: slice (BF.trivial_preorder _) (BF.trivial_preorder _)) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in B.modifies B.loc_none h h' /\ U32.v pos1 + BY.length x == U32.v (get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos) /\ b == BF.gsub input.base pos1 (BY.len x) /\ B.as_seq h b == BY.reveal x ))) = let len = bounded_vlgenbytes_payload_length vmin vmax rk input pos in let pos1 = jk input pos in BF.sub input.base pos1 len let valid_exact_all_bytes_intro (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires ( U32.v pos <= U32.v pos' /\ ( let length = U32.v pos' - U32.v pos in valid (parse_flbytes length) h input pos ))) (ensures ( valid_exact parse_all_bytes h input pos pos' )) = let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "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
vmin: LowParse.Spec.DER.der_length_t -> vmax: LowParse.Spec.DER.der_length_t{vmin <= vmax /\ vmax > 0 /\ vmax < 4294967296} -> pk: LowParse.Spec.Base.parser sk (LowParse.Spec.BoundedInt.bounded_int32 vmin vmax) -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> h: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid pk h input pos /\ (let pos1 = LowParse.Low.Base.Spec.get_valid_pos pk h input pos in let len = LowParse.Low.Base.Spec.contents pk h input pos in FStar.UInt32.v pos1 + FStar.UInt32.v len <= FStar.UInt32.v (Mkslice?.len input))) (ensures (let pos1 = LowParse.Low.Base.Spec.get_valid_pos pk h input pos in let len = LowParse.Low.Base.Spec.contents pk h input pos in let x = FStar.Bytes.hide (LowParse.Low.Base.Spec.bytes_of_slice_from_to h input pos1 (FStar.UInt32.add pos1 len)) in LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Bytes.parse_bounded_vlgenbytes vmin vmax pk) h input pos x (FStar.UInt32.add pos1 len)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.DER.der_length_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "LowParse.Low.Combinators.valid_synth_intro", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.Spec.Bytes.synth_bounded_vlbytes", "Prims.unit", "LowParse.Low.VLGen.valid_bounded_vlgen", "LowParse.Low.Bytes.valid_exact_all_bytes_elim", "LowParse.Low.Bytes.valid_exact_all_bytes_intro", "FStar.UInt32.add", "LowParse.Low.Bytes.valid_flbytes_intro", "FStar.UInt32.v", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Low.Base.Spec.valid", "Prims.op_Addition", "LowParse.Slice.__proj__Mkslice__item__len", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes", "FStar.Bytes.hide", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let valid_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t{vmin <= vmax /\ vmax > 0 /\ vmax < 4294967296}) (#sk: parser_kind) (pk: parser sk (bounded_int32 (vmin) (vmax))) #rrel #rel (input: slice rrel rel) (pos: U32.t) (h: HS.mem) : Lemma (requires (valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len))) (ensures (let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in let x = BY.hide (bytes_of_slice_from_to h input pos1 (pos1 `U32.add` len)) in valid_content_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos x (pos1 `U32.add` len))) =
let pos1 = get_valid_pos pk h input pos in let len = contents pk h input pos in valid_flbytes_intro h (U32.v len) input pos1; let pos' = pos1 `U32.add` len in valid_exact_all_bytes_intro h input pos1 pos'; valid_exact_all_bytes_elim h input pos1 pos'; valid_bounded_vlgen vmin vmax pk serialize_all_bytes input pos h; valid_synth_intro h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes) (synth_bounded_vlbytes vmin vmax) input pos
false
Pulse.Syntax.Base.fsti
Pulse.Syntax.Base.comp_inames
val comp_inames (c: comp{C_STAtomic? c}) : term
val comp_inames (c: comp{C_STAtomic? c}) : term
let comp_inames (c:comp { C_STAtomic? c }) : term = match c with | C_STAtomic inames _ _ -> inames
{ "file_name": "lib/steel/pulse/Pulse.Syntax.Base.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 423, "start_col": 0, "start_line": 421 }
(* 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.Syntax.Base module RTB = FStar.Reflection.Typing.Builtins module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module RU = Pulse.RuntimeUtils module T = FStar.Tactics.V2 open FStar.List.Tot type constant = R.vconst let var = nat let index = nat type universe = R.universe (* locally nameless. *) let range_singleton_trigger (r:FStar.Range.range) = True let range = r:FStar.Range.range { range_singleton_trigger r } let range_singleton (r:FStar.Range.range) : Lemma (ensures r == FStar.Range.range_0) [SMTPat (range_singleton_trigger r)] = FStar.Sealed.sealed_singl r FStar.Range.range_0 noeq type ppname = { name : RT.pp_name_t; range : range } let ppname_default = { name = FStar.Sealed.seal "_"; range = FStar.Range.range_0 } let mk_ppname (name:RT.pp_name_t) (range:FStar.Range.range) : ppname = { name = name; range = range } let mk_ppname_no_range (s:string) : ppname = { name = FStar.Sealed.seal s; range = FStar.Range.range_0; } noeq type bv = { bv_index : index; bv_ppname : ppname; } noeq type nm = { nm_index : var; nm_ppname : ppname; } type qualifier = | Implicit noeq type fv = { fv_name : R.name; fv_range : range; } let as_fv l = { fv_name = l; fv_range = FStar.Range.range_0 } let not_tv_unknown (t:R.term) = R.inspect_ln t =!= R.Tv_Unknown let host_term = t:R.term { not_tv_unknown t } [@@ no_auto_projectors] noeq type term' = | Tm_Emp : term' | Tm_Pure : p:term -> term' | Tm_Star : l:vprop -> r:vprop -> term' | Tm_ExistsSL : u:universe -> b:binder -> body:vprop -> term' | Tm_ForallSL : u:universe -> b:binder -> body:vprop -> term' | Tm_VProp : term' | Tm_Inv : vprop -> term' | Tm_Inames : term' // type inames | Tm_EmpInames : term' | Tm_AddInv : i:term -> is:term -> term' | Tm_FStar : host_term -> term' | Tm_Unknown : term' and vprop = term and typ = term and binder = { binder_ty : term; binder_ppname : ppname; binder_attrs : FStar.Sealed.Inhabited.sealed #(list term) [] } and term = { t : term'; range : range; } let binder_attrs_default = FStar.Sealed.seal [] let term_range (t:term) = t.range let tm_fstar (t:host_term) (r:range) : term = { t = Tm_FStar t; range=r } let with_range (t:term') (r:range) = { t; range=r } let tm_vprop = with_range Tm_VProp FStar.Range.range_0 let tm_inv p = with_range (Tm_Inv p) FStar.Range.range_0 let tm_inames = with_range Tm_Inames FStar.Range.range_0 let tm_emp = with_range Tm_Emp FStar.Range.range_0 let tm_emp_inames = with_range Tm_EmpInames FStar.Range.range_0 let tm_unknown = with_range Tm_Unknown FStar.Range.range_0 let tm_pure (p:term) : term = { t = Tm_Pure p; range = p.range } let tm_star (l:vprop) (r:vprop) : term = { t = Tm_Star l r; range = RU.union_ranges l.range r.range } let tm_exists_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ExistsSL u b body; range = RU.union_ranges b.binder_ty.range body.range } let tm_forall_sl (u:universe) (b:binder) (body:vprop) : term = { t = Tm_ForallSL u b body; range = RU.union_ranges b.binder_ty.range body.range } noeq type st_comp = { (* ST pre (x:res) post ... x is free in post *) u:universe; res:term; pre:vprop; post:vprop } type observability = | Neutral | Observable | Unobservable noeq type comp = | C_Tot : term -> comp | C_ST : st_comp -> comp | C_STAtomic : inames:term -> obs:observability -> st_comp -> comp | C_STGhost : st_comp -> comp let comp_st = c:comp {not (C_Tot? c) } noeq type pattern = | Pat_Cons : fv -> list (pattern & bool) -> pattern | Pat_Constant : constant -> pattern | Pat_Var : RT.pp_name_t -> ty:RT.sort_t -> pattern | Pat_Dot_Term : option term -> pattern type ctag = | STT | STT_Atomic | STT_Ghost let effect_hint = FStar.Sealed.Inhabited.sealed #(option ctag) None let default_effect_hint : effect_hint = FStar.Sealed.seal None let as_effect_hint (c:ctag) : effect_hint = FStar.Sealed.seal (Some c) let ctag_of_comp_st (c:comp_st) : ctag = match c with | C_ST _ -> STT | C_STAtomic _ _ _ -> STT_Atomic | C_STGhost _ -> STT_Ghost noeq type effect_annot = | EffectAnnotSTT | EffectAnnotGhost | EffectAnnotAtomic { opens:term } let effect_annot_of_comp (c:comp_st) : effect_annot = match c with | C_ST _ -> EffectAnnotSTT | C_STGhost _ -> EffectAnnotGhost | C_STAtomic opens _ _ -> EffectAnnotAtomic { opens } let ctag_of_effect_annot = function | EffectAnnotSTT -> STT | EffectAnnotGhost -> STT_Ghost | _ -> STT_Atomic noeq type proof_hint_type = | ASSERT { p:vprop } | FOLD { names:option (list string); p:vprop; } | UNFOLD { names:option (list string); p:vprop } | RENAME { //rename e as e' [in p] pairs:list (term & term); goal: option term } | REWRITE { t1:vprop; t2:vprop; } | WILD //with p q r. _ | SHOW_PROOF_STATE of range //print the proof state and exit noeq type comp_ascription = { annotated:option comp; elaborated:option comp } let empty_ascription = { annotated=None; elaborated=None } (* terms with STT types *) [@@ no_auto_projectors] noeq type st_term' = | Tm_Return { expected_type:term; insert_eq:bool; term: term; } | Tm_Abs { b:binder; q:option qualifier; ascription: comp_ascription; body:st_term; } | Tm_STApp { head:term; arg_qual:option qualifier; arg:term; } | Tm_Bind { binder:binder; head:st_term; body:st_term; } | Tm_TotBind { // tot here means non-stateful, head could also be ghost, we should rename it binder:binder; head:term; body:st_term; } | Tm_If { b:term; then_:st_term; else_:st_term; post:option vprop; } | Tm_Match { sc:term; returns_:option vprop; brs: list branch; } | Tm_IntroPure { p:term; } | Tm_ElimExists { p:vprop; } | Tm_IntroExists { p:vprop; witnesses:list term; } | Tm_While { invariant:term; condition:st_term; condition_var: ppname; body:st_term; } | Tm_Par { pre1:term; body1:st_term; post1:term; pre2:term; body2:st_term; post2:term; } | Tm_WithLocal { binder:binder; initializer:term; body:st_term; } | Tm_WithLocalArray { binder:binder; initializer:term; length:term; body:st_term; } | Tm_Rewrite { t1:term; t2:term; } | Tm_Admit { ctag:ctag; u:universe; typ:term; post:option term; } | Tm_Unreachable | Tm_ProofHintWithBinders { hint_type:proof_hint_type; binders:list binder; t:st_term } | Tm_WithInv { name : term; // invariant name is an F* term that is an Tm_fvar or Tm_name body : st_term; returns_inv : option (binder & vprop); } and st_term = { term : st_term'; range : range; effect_tag: effect_hint } and branch = pattern & st_term noeq type decl' = | FnDecl { (* A function declaration, currently the only Pulse top-level decl. This will be mostly checked as a nested Tm_Abs with bs and body, especially if non-recursive. *) id : R.ident; isrec : bool; bs : list (option qualifier & binder & bv); comp : comp; (* bs in scope *) meas : (meas:option term{Some? meas ==> isrec}); (* bs in scope *) body : st_term; (* bs in scope *) } and decl = { d : decl'; range : range; } let mk_binder_with_attrs (binder_ty:term) (binder_ppname:ppname) binder_attrs : binder = {binder_ty;binder_ppname;binder_attrs} let null_binder (t:term) : binder = mk_binder_with_attrs t ppname_default binder_attrs_default let mk_binder (s:string) (r:range) (t:term) : binder = mk_binder_with_attrs t (mk_ppname (RT.seal_pp_name s) r) binder_attrs_default let mk_binder_ppname (binder_ty:term) (binder_ppname:ppname) : binder = mk_binder_with_attrs binder_ty binder_ppname binder_attrs_default val eq_univ (u1 u2:universe) : b:bool { b <==> (u1 == u2) } val eq_tm (t1 t2:term) : b:bool { b <==> (t1 == t2) } val eq_st_comp (s1 s2:st_comp) : b:bool { b <==> (s1 == s2) } val eq_comp (c1 c2:comp) : b:bool { b <==> (c1 == c2) } val eq_tm_opt (t1 t2:option term) : b:bool { b <==> (t1 == t2) } val eq_tm_list (t1 t2:list term) : b:bool { b <==> (t1 == t2) } val eq_st_term (t1 t2:st_term) : b:bool { b <==> (t1 == t2) } let comp_res (c:comp) : term = match c with | C_Tot ty -> ty | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s.res let stateful_comp (c:comp) = C_ST? c || C_STAtomic? c || C_STGhost? c let st_comp_of_comp (c:comp{stateful_comp c}) : st_comp = match c with | C_ST s | C_STAtomic _ _ s | C_STGhost s -> s let with_st_comp (c:comp{stateful_comp c}) (s:st_comp) : comp = match c with | C_ST _ -> C_ST s | C_STAtomic inames obs _ -> C_STAtomic inames obs s | C_STGhost _ -> C_STGhost s let comp_u (c:comp { stateful_comp c }) = (st_comp_of_comp c).u let universe_of_comp (c:comp_st) = match c with | C_ST _ -> RT.u_zero | _ -> Pulse.Reflection.Util.u_max_two (comp_u c) let comp_pre (c:comp { stateful_comp c }) = (st_comp_of_comp c).pre let comp_post (c:comp { stateful_comp c }) = (st_comp_of_comp c).post
{ "checked_file": "/", "dependencies": [ "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Sealed.Inhabited.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.Builtins.fsti.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Syntax.Base.fsti" }
[ { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing.Builtins", "short_module": "RTB" }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Pulse.Syntax.Base.comp{C_STAtomic? c} -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp", "Prims.b2t", "Pulse.Syntax.Base.uu___is_C_STAtomic", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.st_comp" ]
[]
false
false
false
false
false
let comp_inames (c: comp{C_STAtomic? c}) : term =
match c with | C_STAtomic inames _ _ -> inames
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.finalize_bounded_vlbytes'
val finalize_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h)) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos')))
val finalize_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h)) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos')))
let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 27, "end_line": 942, "start_col": 0, "start_line": 907 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> len: FStar.UInt32.t -> FStar.HyperStack.ST.Stack FStar.UInt32.t
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.UInt32.add", "Prims.unit", "LowParse.Low.Bytes.valid_bounded_vlbytes'_intro", "LowParse.Low.Bytes.valid_flbytes_intro", "FStar.UInt32.v", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.BoundedInt.write_bounded_integer", "LowParse.Slice.live_slice", "Prims.op_Addition", "LowParse.Slice.__proj__Mkslice__item__len", "LowParse.Low.Base.writable", "LowParse.Slice.buffer_srel_of_srel", "LowParse.Slice.__proj__Mkslice__item__base", "LowStar.Monotonic.Buffer.modifies", "LowParse.Slice.loc_slice_from_to", "Prims.eq2", "Prims.int", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Low.Base.Spec.get_valid_pos", "FStar.Bytes.bytes", "LowParse.Low.Base.Spec.contents", "FStar.Bytes.hide", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "FStar.UInt32.uint_to_t" ]
[]
false
true
false
false
false
let finalize_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h)) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos'))) =
let h0 = HST.get () in [@@ inline_let ]let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@@ inline_let ]let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.accessor_vlbytes'_slice
val accessor_vlbytes'_slice (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to))
val accessor_vlbytes'_slice (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to))
let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 47, "end_line": 752, "start_col": 0, "start_line": 738 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> from: FStar.UInt32.t -> to: FStar.UInt32.t{FStar.UInt32.v from <= FStar.UInt32.v to /\ FStar.UInt32.v to <= max} -> LowParse.Low.Base.accessor (LowParse.Low.Bytes.gaccessor_vlbytes'_slice min max l from to)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "FStar.UInt32.t", "FStar.UInt32.v", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "Prims.unit", "LowParse.Low.Base.Spec.slice_access_eq", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Base.total_constant_size_parser_kind", "Prims.op_Subtraction", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Low.Bytes.clens_vlbytes_slice", "LowParse.Low.Bytes.gaccessor_vlbytes'_slice", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Slice.bytes_of_slice_from", "LowParse.Low.Base.Spec.valid_facts", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.accessor" ]
[]
false
false
false
false
false
let accessor_vlbytes'_slice (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (from: U32.t) (to: U32.t{U32.v from <= U32.v to /\ U32.v to <= max}) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) =
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in (pos `U32.add` (U32.uint_to_t l)) `U32.add` from
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.valid_bounded_vlbytes'_intro
val valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : Lemma (requires (let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid (parse_flbytes (U32.v len)) h input pos_payload))) (ensures (let sz = l in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len)))
val valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : Lemma (requires (let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid (parse_flbytes (U32.v len)) h input pos_payload))) (ensures (let sz = l in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len)))
let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz)
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 82, "end_line": 877, "start_col": 0, "start_line": 849 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 6, "max_fuel": 2, "max_ifuel": 6, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 128, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> len: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires (let sz = l in min <= FStar.UInt32.v len /\ FStar.UInt32.v len <= max /\ LowParse.Low.Base.Spec.valid (LowParse.Spec.BoundedInt.parse_bounded_integer sz) h input pos /\ LowParse.Low.Base.Spec.contents (LowParse.Spec.BoundedInt.parse_bounded_integer sz) h input pos == len /\ FStar.UInt32.v pos + sz <= 4294967295 /\ (let pos_payload = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v len)) h input pos_payload))) (ensures (let sz = l in let pos_payload = FStar.UInt32.add pos (FStar.UInt32.uint_to_t sz) in LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l) h input pos (LowParse.Low.Base.Spec.contents (LowParse.Spec.Bytes.parse_flbytes (FStar.UInt32.v len) ) h input pos_payload) (FStar.UInt32.add pos_payload len)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.UInt32.v", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "Prims.unit", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.Bytes.parse_bounded_vlbytes_eq", "LowParse.Slice.bytes_of_slice_from", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Low.Base.Spec.valid", "Prims.eq2", "LowParse.Low.Base.Spec.contents", "Prims.op_Addition", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (l: nat{l >= log256' max /\ l <= 4}) (#rrel #rel: _) (input: slice rrel rel) (pos len: U32.t) : Lemma (requires (let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ (let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid (parse_flbytes (U32.v len)) h input pos_payload))) (ensures (let sz = l in let pos_payload = pos `U32.add` (U32.uint_to_t sz) in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len))) =
valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` (U32.uint_to_t sz))
false
LowParse.Low.Bytes.fst
LowParse.Low.Bytes.bounded_vlgenbytes_payload_length
val bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ (let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x))))
val bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ (let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x))))
let bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ ( let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x )))) = let h = HST.get () in valid_synth h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes ) (synth_bounded_vlbytes vmin vmax) input pos; valid_bounded_vlgen_elim vmin vmax pk serialize_all_bytes input pos h; let len = rk input pos in let pos1 = Ghost.hide (get_valid_pos pk h input pos) in valid_exact_all_bytes_elim h input (Ghost.reveal pos1) (Ghost.reveal pos1 `U32.add` len); valid_flbytes_elim h (U32.v len) input (Ghost.reveal pos1); len
{ "file_name": "src/lowparse/LowParse.Low.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 5, "end_line": 1061, "start_col": 0, "start_line": 1015 }
module LowParse.Low.Bytes include LowParse.Spec.Bytes include LowParse.Low.Combinators include LowParse.Low.VLData include LowParse.Low.VLGen include LowParse.Low.Int module U32 = FStar.UInt32 module HS = FStar.HyperStack module B = LowStar.Monotonic.Buffer module BF = LowStar.Buffer // for local variables in store_bytes module BY = LowParse.Bytes32 module HST = FStar.HyperStack.ST module U8 = FStar.UInt8 module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_flbytes (sz: nat) (sz64: U64.t { U64.v sz64 == sz /\ sz < 4294967296 } ) : Tot (validator (parse_flbytes sz)) = validate_total_constant_size (parse_flbytes sz) sz64 () inline_for_extraction let jump_flbytes (sz: nat) (sz32: U32.t { U32.v sz32 == sz } ) : Tot (jumper (parse_flbytes sz)) = jump_constant_size (parse_flbytes sz) sz32 () let valid_flbytes_intro (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (U32.v pos + sz <= U32.v s.len /\ live_slice h s)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_facts (parse_flbytes sz) h s pos let valid_pos_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_pos (parse_flbytes sz) h s pos pos')) (ensures (U32.v pos + sz == U32.v pos')) [SMTPat (valid_pos (parse_flbytes sz) h s pos pos')] = valid_facts (parse_flbytes sz) h s pos let valid_flbytes_elim (h: HS.mem) (sz: nat { sz < 4294967296 } ) (#rrel #rel: _) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_flbytes sz) h s pos)) (ensures ( valid_content_pos (parse_flbytes sz) h s pos (BY.hide (bytes_of_slice_from_to h s pos (pos `U32.add` U32.uint_to_t sz))) (pos `U32.add` U32.uint_to_t sz) )) = valid_flbytes_intro h sz s pos let clens_flbytes_slice (sz: nat) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (clens (BY.lbytes sz) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_flbytes_slice' (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = fun (input: bytes) -> ( begin if Seq.length input < sz then (0) // dummy else (U32.v from) end) let gaccessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) x ==> sz <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_flbytes (U32.v to - U32.v from)) (clens_flbytes_slice sz from to) (gaccessor_flbytes_slice' sz from to); gaccessor_flbytes_slice' sz from to inline_for_extraction let accessor_flbytes_slice (sz: nat { sz < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= sz } ) : Tot (accessor (gaccessor_flbytes_slice sz from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_slice sz from to) input pos in pos `U32.add` from #pop-options let clens_flbytes_get (sz: nat) (i: U32.t { U32.v i < sz } ) : Tot (clens (BY.lbytes sz) byte) = { clens_cond = (fun _ -> True); clens_get = (fun (x: BY.lbytes sz) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16 --max_fuel 1" let gaccessor_flbytes_get' (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor' (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = fun (input: bytes) -> ( begin let res = if Seq.length input < U32.v i then (0) // dummy else (U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input)) (ensures (gaccessor_post (parse_flbytes sz) parse_u8 (clens_flbytes_get sz i) input res)) = parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (U32.v i)); parse_u8_spec' (Seq.slice input (U32.v i) (U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (U32.v i) (U32.v i + 1)) (Seq.slice input (U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) #pop-options let gaccessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (gaccessor (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i)) = assert (forall x . gaccessor_pre (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) x ==> U32.v i <= Seq.length x); gaccessor_prop_equiv (parse_flbytes sz) (parse_u8) (clens_flbytes_get sz i) (gaccessor_flbytes_get' sz i); gaccessor_flbytes_get' sz i inline_for_extraction let accessor_flbytes_get (sz: nat { sz < 4294967296 } ) (i: U32.t { U32.v i < sz } ) : Tot (accessor (gaccessor_flbytes_get sz i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_flbytes_get sz i) input pos in pos `U32.add` i (* Temporary: flbytes as leaf values *) (* TODO: convert store_bytes to monotonic buffers, using the "writable" predicate *) #push-options "--z3rlimit 32" inline_for_extraction let store_bytes (src: BY.bytes) (src_from src_to: U32.t) (#rrel #rel: _) (dst: B.mbuffer byte rrel rel) (dst_pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h dst /\ U32.v src_from <= U32.v src_to /\ U32.v src_to <= BY.length src /\ U32.v dst_pos + (U32.v src_to - U32.v src_from) <= B.length dst /\ writable dst (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) h )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` (src_to `U32.sub` src_from))) h h' /\ Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + (U32.v src_to - U32.v src_from)) == Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_to) )) = let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in let bi = BF.alloca 0ul 1ul in let h2 = HST.get () in let len = src_to `U32.sub` src_from in C.Loops.do_while (fun h stop -> B.modifies (B.loc_union (B.loc_region_only true (HS.get_tip h1)) (B.loc_buffer_from_to dst dst_pos (dst_pos `U32.add` len))) h2 h /\ B.live h bi /\ ( let i = Seq.index (B.as_seq h bi) 0 in U32.v i <= U32.v len /\ writable dst (U32.v dst_pos) (U32.v dst_pos + U32.v len) h /\ Seq.slice (B.as_seq h dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i) `Seq.equal` Seq.slice (BY.reveal src) (U32.v src_from) (U32.v src_from + U32.v i) /\ (stop == true ==> i == len) )) (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let x = BY.get src (src_from `U32.add` i) in mbuffer_upd dst (Ghost.hide (U32.v dst_pos)) (Ghost.hide (U32.v dst_pos + U32.v len)) (dst_pos `U32.add` i) x; let i' = i `U32.add` 1ul in B.upd bi 0ul i'; let h' = HST.get () in Seq.lemma_split (Seq.slice (B.as_seq h' dst) (U32.v dst_pos) (U32.v dst_pos + U32.v i')) (U32.v i); i' = len end ) ; HST.pop_frame () #pop-options inline_for_extraction let serialize32_flbytes (sz32: U32.t) : Tot (serializer32 (serialize_flbytes (U32.v sz32))) = fun (x: BY.lbytes (U32.v sz32)) #rrel #rel b pos -> let _ = store_bytes x 0ul sz32 b pos in sz32 inline_for_extraction let write_flbytes (sz32: U32.t) : Tot (leaf_writer_strong (serialize_flbytes (U32.v sz32))) = leaf_writer_strong_of_serializer32 (serialize32_flbytes sz32) () inline_for_extraction let write_flbytes_weak (sz32: U32.t { U32.v sz32 < 4294967295 } ) // need to return that value if output buffer is too small : Tot (leaf_writer_weak (serialize_flbytes (U32.v sz32))) = leaf_writer_weak_of_strong_constant_size (write_flbytes sz32) sz32 () (* // TODO: remove, since nobody is using this inline_for_extraction let read_flbytes (sz32: U32.t) : Tot (leaf_reader (parse_flbytes (U32.v sz32))) = fun input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v sz32)) h input pos in BY.of_buffer sz32 (B.sub input.base pos sz32) *) (* Equality test between a vlbytes and a constant lbytes *) #push-options "--z3rlimit 32" inline_for_extraction let buffer_equals_bytes (const: BY.bytes) (#rrel #rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> B.live h b /\ U32.v pos + BY.length const <= B.length b )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + BY.length const) == BY.reveal const) )) = let h0 = HST.get () in HST.push_frame (); let len = BY.len const in let bi = BF.alloca 0ul 1ul in let bres = BF.alloca true 1ul in let h1 = HST.get () in [@inline_let] let inv (h: HS.mem) (stop: bool) : GTot Type0 = B.modifies (B.loc_union (B.loc_buffer bi) (B.loc_buffer bres)) h1 h /\ ( let length = U32.v len in let i32 = (Seq.index (B.as_seq h bi) 0) in let i = U32.v i32 in let res = Seq.index (B.as_seq h bres) 0 in i <= length /\ (stop == false ==> res == true) /\ ((stop == true /\ res == true) ==> i == length) /\ (res == true <==> Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + i) `Seq.equal` Seq.slice (BY.reveal const) 0 i) ) in C.Loops.do_while inv (fun _ -> let i = B.index bi 0ul in if i = len then true else begin let i' = i `U32.add` 1ul in [@inline_let] let _ = let s1 = (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i)) in let c1 = (B.get h0 b (U32.v pos + U32.v i)) in let s2 = (Seq.slice (BY.reveal const) 0 (U32.v i)) in let c2 = (BY.index const (U32.v i)) in assert (Seq.slice (B.as_seq h0 b) (U32.v pos) (U32.v pos + U32.v i') `Seq.equal` Seq.snoc s1 c1); assert (Seq.slice (BY.reveal const) 0 (U32.v i') `Seq.equal` Seq.snoc s2 c2); Classical.move_requires (Seq.lemma_snoc_inj s1 s2 c1) c2 in let res = B.index b (pos `U32.add` i) = BY.get const i in B.upd bres 0ul res; B.upd bi 0ul i'; not res end ); let res = B.index bres 0ul in HST.pop_frame (); res #pop-options inline_for_extraction let valid_slice_equals_bytes (const: BY.bytes) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack bool (requires (fun h -> valid (parse_flbytes (BY.length const)) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ (res == true <==> contents (parse_flbytes (BY.length const)) h input pos == const ))) = let h = HST.get () in [@inline_let] let _ = valid_facts (parse_flbytes (BY.length const)) h input pos in buffer_equals_bytes const input.base pos inline_for_extraction let validate_all_bytes () : Tot (validator parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input (uint64_to_uint32 pos) in Cast.uint32_to_uint64 input.len inline_for_extraction let validate_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (validator (parse_bounded_vlbytes' min max l)) = validate_synth (validate_bounded_vldata_strong' min max l serialize_all_bytes (validate_all_bytes ())) (synth_bounded_vlbytes min max) () inline_for_extraction let validate_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (validator (parse_bounded_vlbytes min max)) = validate_bounded_vlbytes' min max (log256' max) inline_for_extraction let jump_all_bytes () : Tot (jumper parse_all_bytes) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_all_bytes h input pos in input.len inline_for_extraction let jump_bounded_vlbytes' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (jumper (parse_bounded_vlbytes' min max l)) = jump_synth (jump_bounded_vldata_strong' min max l serialize_all_bytes) (synth_bounded_vlbytes min max) () inline_for_extraction let jump_bounded_vlbytes (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) : Tot (jumper (parse_bounded_vlbytes min max)) = jump_bounded_vlbytes' min max (log256' max) let valid_exact_all_bytes_elim (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos pos' : U32.t) : Lemma (requires (valid_exact parse_all_bytes h input pos pos')) (ensures ( let x = contents_exact parse_all_bytes h input pos pos' in let length = U32.v pos' - U32.v pos in BY.length x == length /\ valid_content_pos (parse_flbytes length) h input pos x pos' )) = valid_exact_equiv parse_all_bytes h input pos pos' ; contents_exact_eq parse_all_bytes h input pos pos' ; let length = U32.v pos' - U32.v pos in valid_facts (parse_flbytes length) h input pos ; assert (no_lookahead_on (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)); assert (injective_postcond (parse_flbytes length) (bytes_of_slice_from_to h input pos pos') (bytes_of_slice_from h input pos)) #push-options "--z3rlimit 32" let valid_bounded_vlbytes'_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes' min max l) h input pos )) (ensures ( let sz = l in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes' min max l) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes' min max l) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_synth h (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) input pos; valid_bounded_vldata_strong'_elim h min max l serialize_all_bytes input pos; let sz = l in let len_payload = contents (parse_bounded_integer sz) h input pos in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_exact_all_bytes_elim h input pos_payload (pos_payload `U32.add` len_payload); () #pop-options let valid_bounded_vlbytes_elim (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( let sz = log256' max in valid (parse_bounded_integer sz) h input pos /\ ( let len_payload = contents (parse_bounded_integer sz) h input pos in min <= U32.v len_payload /\ U32.v len_payload <= max /\ sz + U32.v len_payload == content_length (parse_bounded_vlbytes min max) h input pos /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in let x = contents (parse_bounded_vlbytes min max) h input pos in BY.len x == len_payload /\ valid_pos (parse_bounded_vlbytes min max) h input pos (pos_payload `U32.add` len_payload) /\ valid_content_pos (parse_flbytes (U32.v len_payload)) h input pos_payload x (pos_payload `U32.add` len_payload) )))) = valid_bounded_vlbytes'_elim h min max (log256' max) input pos let valid_bounded_vlbytes_elim_length (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_bounded_vlbytes min max) h input pos )) (ensures ( content_length (parse_bounded_vlbytes min max) h input pos == log256' max + BY.length (contents (parse_bounded_vlbytes min max) h input pos) )) [SMTPat (valid (parse_bounded_vlbytes min max) h input pos)] = valid_bounded_vlbytes_elim h min max input pos inline_for_extraction let bounded_vlbytes'_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + l + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes' min max l) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes' min max l) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t l) pos' == BY.reveal x ))) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_flbytes_elim h (U32.v len) input (pos `U32.add` U32.uint_to_t l) in len inline_for_extraction let bounded_vlbytes_payload_length (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ U32.v pos + log256' max + U32.v len <= U32.v input.len /\ ( let x = contents (parse_bounded_vlbytes min max) h input pos in let pos' = get_valid_pos (parse_bounded_vlbytes min max) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t (log256' max)) x pos' /\ bytes_of_slice_from_to h input (pos `U32.add` U32.uint_to_t (log256' max)) pos' == BY.reveal x ))) = bounded_vlbytes'_payload_length min max (log256' max) input pos (* Get the content buffer (with trivial buffers only, not generalizable to monotonicity) *) #push-options "--z3rlimit 32" inline_for_extraction let get_vlbytes'_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes' min max l) h input pos)) (ensures (fun h b h' -> let x = contents (parse_bounded_vlbytes' min max l) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = let h = HST.get () in [@inline_let] let _ = valid_bounded_vlbytes'_elim h min max l input pos in let len = read_bounded_integer l input pos in [@inline_let] let _ = valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t l) in BF.sub input.base (pos `U32.add` U32.uint_to_t l) len #pop-options inline_for_extraction let get_vlbytes_contents (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (input: slice (srel_of_buffer_srel (BF.trivial_preorder _)) (srel_of_buffer_srel (BF.trivial_preorder _))) (pos: U32.t) : HST.Stack (BF.buffer byte) (requires (fun h -> valid (parse_bounded_vlbytes min max) h input pos)) (ensures (fun h b h' -> let l = log256' max in let x = contents (parse_bounded_vlbytes min max) h input pos in B.modifies B.loc_none h h' /\ U32.v pos + l + BY.length x <= U32.v input.len /\ b == BF.gsub input.base (pos `U32.add` U32.uint_to_t l) (BY.len x) /\ B.as_seq h b == BY.reveal x )) = get_vlbytes'_contents min max (log256' max) input pos (* In fact, the following accessors are not useful in practice, because users would need to have the flbytes parser combinator in their scope *) let clens_vlbytes_cond (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) (x: parse_bounded_vlbytes_t min max) : GTot Type0 = BY.length x == length let clens_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes length)) = { clens_cond = (clens_vlbytes_cond min max length); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (x <: Ghost (BY.lbytes length) (requires (clens_vlbytes_cond min max length x)) (ensures (fun _ -> True)))); } #push-options "--z3rlimit 16 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let gaccessor_vlbytes'_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = fun (input: bytes) -> (begin let res = if Seq.length input >= l then (l) else (0) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) input res)) = parse_bounded_vlbytes_eq min max l input; parse_strong_prefix (parse_flbytes length) (Seq.slice input l (l + length)) (Seq.slice input l (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) x ==> Seq.length x >= l); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes length) (clens_vlbytes min max length) (gaccessor_vlbytes'_aux min max l length); gaccessor_vlbytes'_aux min max l length #pop-options let gaccessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: nat { length < 4294967296 } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes length) (clens_vlbytes min max length)) = gaccessor_vlbytes' min max (log256' max) length #push-options "--z3rlimit 64 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" inline_for_extraction let accessor_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes' min max l (U32.v length))) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_vlbytes' min max l (U32.v length)) sl pos; valid_bounded_vlbytes'_elim h min max l sl pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h sl pos) in pos `U32.add` U32.uint_to_t l #pop-options inline_for_extraction let accessor_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (length: U32.t) : Tot (accessor (gaccessor_vlbytes min max (U32.v length))) = accessor_vlbytes' min max (log256' max) length let clens_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (clens (parse_bounded_vlbytes_t min max) (BY.lbytes (U32.v to - U32.v from))) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v to <= BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.slice x from to <: BY.lbytes (U32.v to - U32.v from))); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_slice_aux (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = fun (input: bytes) -> ( begin parse_bounded_vlbytes_eq min max l input; if Seq.length input < l + U32.v to then (0) // dummy else (l + U32.v from) end) let gaccessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = parser_kind_prop_equiv (parse_bounded_vldata_strong_kind min max l parse_all_bytes_kind) (parse_bounded_vlbytes' min max l); Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) x ==> l + U32.v to <= Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to) (gaccessor_vlbytes'_slice_aux min max l from to); gaccessor_vlbytes'_slice_aux min max l from to let gaccessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_flbytes (U32.v to - U32.v from)) (clens_vlbytes_slice min max from to)) = gaccessor_vlbytes'_slice min max (log256' max) from to #pop-options #push-options "--z3rlimit 50" inline_for_extraction let accessor_vlbytes'_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes'_slice min max l from to)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_slice min max l from to) input pos in pos `U32.add` U32.uint_to_t l `U32.add` from #pop-options inline_for_extraction let accessor_vlbytes_slice (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (from: U32.t) (to: U32.t {U32.v from <= U32.v to /\ U32.v to <= max } ) : Tot (accessor (gaccessor_vlbytes_slice min max from to)) = accessor_vlbytes'_slice min max (log256' max) from to let clens_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (clens (parse_bounded_vlbytes_t min max) byte) = { clens_cond = (fun (x: parse_bounded_vlbytes_t min max) -> U32.v i < BY.length x); clens_get = (fun (x: parse_bounded_vlbytes_t min max) -> (BY.get x i <: byte)); } #push-options "--z3rlimit 16" let gaccessor_vlbytes'_get' (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor' (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = fun (input: bytes) -> ( begin let res = if Seq.length input <= l + U32.v i then (0) // dummy else (l + U32.v i) in let g () : Lemma (requires (gaccessor_pre (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input)) (ensures (gaccessor_post (parse_bounded_vlbytes' min max l) parse_u8 (clens_vlbytes_get min max i) input res)) = parse_bounded_vlbytes_eq min max l input; parser_kind_prop_equiv (get_parser_kind parse_u8) parse_u8; assert (res == (l + U32.v i)); parse_u8_spec' (Seq.slice input (l + U32.v i) (l + U32.v i + 1)); parse_strong_prefix parse_u8 (Seq.slice input (l + U32.v i) (l + U32.v i + 1)) (Seq.slice input (l + U32.v i) (Seq.length input)) in Classical.move_requires g (); res end) let gaccessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i)) = Classical.forall_intro (parse_bounded_vlbytes_eq min max l); assert (forall x . gaccessor_pre (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) x ==> l + U32.v i < Seq.length x); gaccessor_prop_equiv (parse_bounded_vlbytes' min max l) (parse_u8) (clens_vlbytes_get min max i) (gaccessor_vlbytes'_get' min max l i); gaccessor_vlbytes'_get' min max l i inline_for_extraction let accessor_vlbytes'_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes'_get min max l i)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); slice_access_eq h (gaccessor_vlbytes'_get min max l i) input pos in pos `U32.add` U32.uint_to_t l `U32.add` i #pop-options let gaccessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (gaccessor (parse_bounded_vlbytes min max) (parse_u8) (clens_vlbytes_get min max i)) = gaccessor_vlbytes'_get min max (log256' max) i inline_for_extraction let accessor_vlbytes_get (min: nat) // must be a constant (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (i: U32.t) : Tot (accessor (gaccessor_vlbytes_get min max i)) = accessor_vlbytes'_get min max (log256' max) i #push-options "--z3rlimit 128 --max_fuel 2 --initial_fuel 2 --max_ifuel 6 --initial_ifuel 6" let valid_bounded_vlbytes'_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = l in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes' min max l) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_facts (parse_bounded_vlbytes' min max l) h input pos; parse_bounded_vlbytes_eq min max l (bytes_of_slice_from h input pos); let sz = l in valid_facts (parse_bounded_integer sz) h input pos; valid_facts (parse_flbytes (U32.v len)) h input (pos `U32.add` U32.uint_to_t sz) #pop-options let valid_bounded_vlbytes_intro (h: HS.mem) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : Lemma (requires ( let sz = log256' max in min <= U32.v len /\ U32.v len <= max /\ valid (parse_bounded_integer sz) h input pos /\ contents (parse_bounded_integer sz) h input pos == len /\ U32.v pos + sz <= 4294967295 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t sz in valid (parse_flbytes (U32.v len)) h input pos_payload ))) (ensures ( let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in valid_content_pos (parse_bounded_vlbytes min max) h input pos (contents (parse_flbytes (U32.v len)) h input pos_payload) (pos_payload `U32.add` len) )) = valid_bounded_vlbytes'_intro h min max (log256' max) input pos len inline_for_extraction let finalize_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (l: nat { l >= log256' max /\ l <= 4 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = l in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = l in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos_payload + U32.v len == U32.v pos' /\ U32.v pos' <= U32.v input.len /\ valid (parse_bounded_vlbytes' min max l) h' input pos /\ get_valid_pos (parse_bounded_vlbytes' min max l) h' input pos == pos' /\ contents (parse_bounded_vlbytes' min max l) h' input pos == BY.hide (bytes_of_slice_from_to h input pos_payload pos') )) = let h0 = HST.get () in [@inline_let] let sz = l in let pos_payload = write_bounded_integer sz len input pos in let h = HST.get () in [@inline_let] let _ = valid_flbytes_intro h0 (U32.v len) input pos_payload; valid_bounded_vlbytes'_intro h min max l input pos len in pos_payload `U32.add` len inline_for_extraction let finalize_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 } ) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) (len: U32.t) : HST.Stack U32.t (requires (fun h -> let sz = log256' max in live_slice h input /\ min <= U32.v len /\ U32.v len <= max /\ U32.v pos + sz + U32.v len <= U32.v input.len /\ writable input.base (U32.v pos) (U32.v pos + sz) h )) (ensures (fun h pos' h' -> let sz = log256' max in let pos_payload = pos `U32.add` U32.uint_to_t sz in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ U32.v pos' == U32.v pos_payload + U32.v len /\ valid_content_pos (parse_bounded_vlbytes min max) h' input pos (BY.hide (bytes_of_slice_from_to h input pos_payload pos')) pos' )) = finalize_bounded_vlbytes' min max (log256' max) input pos len inline_for_extraction let validate_bounded_vlgenbytes (vmin: der_length_t) (min: U32.t { U32.v min == vmin } ) (vmax: der_length_t { vmax > 0 }) (max: U32.t { U32.v max == vmax /\ U32.v min <= U32.v max } ) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: validator pk) (rk: leaf_reader pk) : Tot (validator (parse_bounded_vlgenbytes vmin vmax pk)) = validate_synth (validate_bounded_vlgen vmin min vmax max vk rk serialize_all_bytes (validate_all_bytes ()) ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) () inline_for_extraction let jump_bounded_vlgenbytes (vmin: der_length_t) (vmax: der_length_t { vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (vk: jumper pk) (rk: leaf_reader pk) : Tot (jumper (parse_bounded_vlgenbytes vmin vmax pk)) = jump_synth (jump_bounded_vlgen vmin vmax vk rk serialize_all_bytes ) (fun x -> (x <: parse_bounded_vlbytes_t vmin vmax)) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.Low.VLGen.fst.checked", "LowParse.Low.VLData.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "LowParse.Low.Bytes.fst" }
[ { "abbrev": true, "full_module": "LowStar.Buffer // for local variables in store_bytes", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "BY" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "BF" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Int", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "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
vmin: LowParse.Spec.DER.der_length_t -> vmax: LowParse.Spec.DER.der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296} -> rk: LowParse.Low.Base.leaf_reader pk -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack FStar.UInt32.t
FStar.HyperStack.ST.Stack
[]
[]
[ "LowParse.Spec.DER.der_length_t", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Low.Base.leaf_reader", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Bytes.valid_flbytes_elim", "FStar.UInt32.v", "FStar.Ghost.reveal", "LowParse.Low.Bytes.valid_exact_all_bytes_elim", "FStar.UInt32.add", "FStar.Ghost.erased", "FStar.Ghost.hide", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Low.VLGen.valid_bounded_vlgen_elim", "LowParse.Spec.Bytes.parse_all_bytes_kind", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Low.Combinators.valid_synth", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.Spec.Bytes.synth_bounded_vlbytes", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.op_Addition", "LowParse.Slice.__proj__Mkslice__item__len", "Prims.eq2", "FStar.Bytes.len", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "FStar.Seq.Base.seq", "FStar.Bytes.byte", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "FStar.Bytes.reveal", "LowParse.Low.Base.Spec.contents" ]
[]
false
true
false
false
false
let bounded_vlgenbytes_payload_length (vmin: der_length_t) (vmax: der_length_t{vmax > 0 /\ vmin <= vmax /\ vmax < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 (vmin) (vmax))) (rk: leaf_reader pk) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_bounded_vlgenbytes vmin vmax pk) h input pos)) (ensures (fun h len h' -> B.modifies B.loc_none h h' /\ valid pk h input pos /\ (let pos1 = get_valid_pos pk h input pos in U32.v pos1 + U32.v len <= U32.v input.len /\ (let x = contents (parse_bounded_vlgenbytes vmin vmax pk) h input pos in let pos' = get_valid_pos (parse_bounded_vlgenbytes vmin vmax pk) h input pos in BY.len x == len /\ valid_content_pos (parse_flbytes (U32.v len)) h input pos1 x pos' /\ bytes_of_slice_from_to h input pos1 pos' == BY.reveal x)))) =
let h = HST.get () in valid_synth h (parse_bounded_vlgen vmin vmax pk serialize_all_bytes) (synth_bounded_vlbytes vmin vmax) input pos; valid_bounded_vlgen_elim vmin vmax pk serialize_all_bytes input pos h; let len = rk input pos in let pos1 = Ghost.hide (get_valid_pos pk h input pos) in valid_exact_all_bytes_elim h input (Ghost.reveal pos1) ((Ghost.reveal pos1) `U32.add` len); valid_flbytes_elim h (U32.v len) input (Ghost.reveal pos1); len
false
Vale.Poly1305.X64.fst
Vale.Poly1305.X64.va_qcode_Poly1305_impl
val va_qcode_Poly1305_impl (va_mods: va_mods_t) (key_r key_s: nat128) (ctx_b inp_b: buffer64) (finish: nat64) : (va_quickCode (int) (va_code_Poly1305_impl ()))
val va_qcode_Poly1305_impl (va_mods: va_mods_t) (key_r key_s: nat128) (ctx_b inp_b: buffer64) (finish: nat64) : (va_quickCode (int) (va_code_Poly1305_impl ()))
let va_qcode_Poly1305_impl (va_mods:va_mods_t) (key_r:nat128) (key_s:nat128) (ctx_b:buffer64) (inp_b:buffer64) (finish:nat64) : (va_quickCode (int) (va_code_Poly1305_impl ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (inp_in:nat64) = va_get_reg64 rRsi va_s in let (len_in:nat64) = va_get_reg64 rRdx va_s in let (h0_in:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_s) in let (h1_in:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_s) in let (h2_in:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_s) in let (h_in:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 h0_in h1_in) h2_in in let (key_r0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_s) in let (key_r1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_s) in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 607 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 609 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public ctx_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 610 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR12) (va_op_reg_opr64_reg64 rRdi) 32 Public ctx_b 4) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 611 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413247)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 612 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 613 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413244)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 614 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 615 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Public ctx_b 3) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 616 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR12) 32 Public ctx_b 4) (fun (va_s:va_state) _ -> let (r:nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s) (va_get_reg64 rR12 va_s) in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 619 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (r == va_get_reg64 rR11 va_s + va_mul_nat n (va_get_reg64 rR12 va_s)) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 619 column 54 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (()))) (let (mask:nat128) = 21267647620597763993911028882763415551 in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 622 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (r == Vale.Arch.Types.iand128 key_r mask) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 624 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (let (va_arg81:Vale.Def.Types_s.nat64) = va_get_reg64 rR12 va_s in let (va_arg80:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg79:Vale.Def.Words_s.nat128) = r in let (va_arg78:Vale.Def.Words_s.nat128) = mask in let (va_arg77:Vale.Def.Words_s.nat128) = key_r in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 625 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_lowerUpper128_and va_arg77 key_r0 key_r1 va_arg78 1152921487695413247 1152921487695413244 va_arg79 va_arg80 va_arg81) (va_QEmpty (())))) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 629 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 630 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 15)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 631 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 634 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRax) 56 Public ctx_b 7) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 635 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 64 Public ctx_b 8) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 637 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (fun (va_s:va_state) _ -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 638 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h_in == va_mul_nat h2_in (va_mul_nat n n) + va_mul_nat h1_in n + h0_in) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 638 column 81 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 638 column 105 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper192_reveal ()) (va_QEmpty (())))) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 639 column 7 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_blocks r h_in ctx_b inp_b) (fun (va_s:va_state) (h:int) -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 640 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s)) (va_get_reg64 rRbp va_s)) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 641 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper192_reveal ()) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 641 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (())))) (let (va_arg76:Prims.int) = va_get_reg64 rRdx va_old_s `op_Division` 16 in let (va_arg75:Vale.X64.Memory.buffer64) = inp_b in let (va_arg74:Vale.X64.Memory.vale_heap) = va_get_mem_heaplet 0 va_s in let (va_arg73:Prims.int) = r in let (va_arg72:Prims.int) = va_mul_nat n n in let (va_arg71:Prims.int) = Vale.Poly1305.Spec_s.modp h_in in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 642 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Util.lemma_poly1305_heap_hash_blocks_alt va_arg71 va_arg72 va_arg73 va_arg74 va_arg75 va_arg76) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 644 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 184 Public ctx_b 23) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 645 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_qIf va_mods (Cmp_eq (va_op_cmp_reg64 rRax) (va_const_cmp 1)) (qblock va_mods (fun (va_s:va_state) -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 647 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> reveal_logand128 key_r mask) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 648 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (r == Vale.Poly1305.Math.bare_r key_r) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 650 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRdi) 56 Public ctx_b 7) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 652 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_qIf va_mods (Cmp_ne (va_op_cmp_reg64 rR15) (va_const_cmp 0)) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 654 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 32 Public ctx_b 4) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 655 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Public inp_b (len_in `op_Division` 16 `op_Multiply` 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 656 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Public inp_b (len_in `op_Division` 16 `op_Multiply` 2 + 1)) (fun (va_s:va_state) _ -> let (a:Vale.X64.Machine_s.nat128) = Vale.Poly1305.Util.seqTo128_app (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b) (len_in `op_Division` 16) in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 658 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s) (va_get_reg64 rR9 va_s) == a) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 659 column 42 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (()))) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 660 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_last_block ()) (fun (va_s:va_state) _ -> let (h:int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s)) (va_get_reg64 rRbp va_s) in va_QEmpty ((h))))))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty ((h))))) (fun (va_s:va_state) va_g -> let (h:int) = va_g in let (va_arg70:Prims.int) = key_s in let (va_arg69:Prims.int) = Vale.Poly1305.Spec_s.modp h in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 664 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_add_mod128 va_arg69 va_arg70) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 665 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_reduce_last ()) (fun (va_s:va_state) _ -> let (h:int) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 668 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 40 Public ctx_b 5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 669 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRdi) 48 Public ctx_b 6) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 670 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_add_key_s ()) (fun (va_s:va_state) _ -> let (h:int) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s) in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 673 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == Vale.Poly1305.Spec_s.poly1305_hash_all (Vale.Poly1305.Spec_s.modp h_in) key_r key_s (Vale.Poly1305.Util.seqTo128 (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b)) len_in) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 674 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true (fun _ -> va_reveal_eq (`%mod2_128) mod2_128 mod2_128) (fun _ -> va_reveal_opaque (`%mod2_128) mod2_128) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 674 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true (fun _ -> va_reveal_eq (`%modp) modp modp) (fun _ -> va_reveal_opaque (`%modp) modp) (va_QEmpty (())))) (va_QEmpty ((h)))))))))))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty ((h))))) (fun (va_s:va_state) va_g -> let (h:int) = va_g in va_QEmpty ((h)))))))))))))))))))))))))))
{ "file_name": "obj/Vale.Poly1305.X64.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 2555, "start_col": 0, "start_line": 2390 }
module Vale.Poly1305.X64 open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Poly1305.Spec_s open Vale.Poly1305.Math open Vale.Poly1305.Util #reset-options "--z3rlimit 40" //-- Poly1305_multiply val va_code_Poly1305_multiply : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_multiply () = (va_Block (va_CCons (va_code_Mul64Wrap (va_op_opr64_reg64 rR14)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mul64Wrap (va_op_opr64_reg64 rR14)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mul64Wrap (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mul64Wrap (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRbp)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_IMul64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_CCons (va_code_IMul64 (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 18446744073709551612)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbp)) (va_CNil ())))))))))))))))))))))))))) val va_codegen_success_Poly1305_multiply : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_multiply () = (va_pbool_and (va_codegen_success_Mul64Wrap (va_op_opr64_reg64 rR14)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mul64Wrap (va_op_opr64_reg64 rR14)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mul64Wrap (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mul64Wrap (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRbp)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 18446744073709551612)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbp)) (va_ttrue ()))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_multiply (va_mods:va_mods_t) (r1:nat64) : (va_quickCode (int) (va_code_Poly1305_multiply ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s) n + va_get_reg64 rR14 va_s in va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 93 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat (va_get_reg64 rR14 va_s) r1 == va_mul_nat r1 (va_get_reg64 rR14 va_s)) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 94 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat (va_get_reg64 rR11 va_s) (va_get_reg64 rR14 va_s) == va_mul_nat (va_get_reg64 rR14 va_s) (va_get_reg64 rR11 va_s)) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 95 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat (va_get_reg64 rR11 va_s) (va_get_reg64 rRbx va_s) == va_mul_nat (va_get_reg64 rRbx va_s) (va_get_reg64 rR11 va_s)) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 97 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat (va_get_reg64 rR13 va_s) (va_get_reg64 rRbx va_s) == va_mul_nat (va_get_reg64 rRbx va_s) (va_get_reg64 rR13 va_s)) (let (gd0:int) = va_mul_nat (va_get_reg64 rR14 va_s) (va_get_reg64 rR11 va_s) + va_mul_nat (va_get_reg64 rRbx va_s) (va_get_reg64 rR13 va_s) in let (gd1:int) = va_mul_nat (va_get_reg64 rR14 va_s) r1 + va_mul_nat (va_get_reg64 rRbx va_s) (va_get_reg64 rR11 va_s) + va_mul_nat (va_get_reg64 rRbp va_s) (va_get_reg64 rR13 va_s) in let (gd2:int) = va_mul_nat (va_get_reg64 rRbp va_s) (va_get_reg64 rR11 va_s) in va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 105 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.va_is_src_opr64 (Vale.X64.Decls.va_op_opr64_reg64 rR14) va_s) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 106 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mul64Wrap (va_op_opr64_reg64 rR14)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 107 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 108 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 109 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 112 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mul64Wrap (va_op_opr64_reg64 rR14)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 113 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 114 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 115 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 118 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mul64Wrap (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 119 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 120 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR13)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 121 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 124 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mul64Wrap (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 125 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRbp)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 126 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 127 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 130 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_IMul64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR13)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 131 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 132 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 133 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 136 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_IMul64 (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 138 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 139 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 18446744073709551612)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 140 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbp)) (fun (va_s:va_state) _ -> let (hh:int) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s) + va_mul_nat n (va_get_reg64 rRbx va_s) + va_get_reg64 rR14 va_s in let (va_arg61:Prims.int) = hh in let (va_arg60:Prims.int) = gd2 in let (va_arg59:Prims.int) = gd1 in let (va_arg58:Prims.int) = gd0 in let (va_arg57:Prims.int) = va_get_reg64 rR13 va_s in let (va_arg56:Prims.int) = va_get_reg64 rRbp va_old_s in let (va_arg55:Prims.int) = va_get_reg64 rRbx va_old_s in let (va_arg54:Prims.int) = va_get_reg64 rR14 va_old_s in let (va_arg53:Prims.int) = r1 in let (va_arg52:Prims.int) = va_get_reg64 rR11 va_s in let (va_arg51:Prims.int) = h in let (va_arg50:Prims.int) = r in let (va_arg49:Prims.int) = p in let (va_arg48:Prims.int) = n in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_multiply va_arg48 va_arg49 va_arg50 va_arg51 va_arg52 va_arg53 va_arg54 va_arg55 va_arg56 va_arg57 va_arg58 va_arg59 va_arg60 va_arg61) (va_QEmpty ((hh)))))))))))))))))))))))))))))))))) val va_lemma_Poly1305_multiply : va_b0:va_code -> va_s0:va_state -> r1:nat64 -> Ghost (va_state & va_fuel & int) (requires (va_require_total va_b0 (va_code_Poly1305_multiply ()) va_s0 /\ va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in r1 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == r1 + r1 `op_Division` 4 /\ va_mul_nat (va_get_reg64 rRbp va_s0) (va_get_reg64 rR11 va_s0) < 7 `op_Multiply` (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rR14 va_s0) r1 < va_mul_nat n (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rRbx va_s0) (va_get_reg64 rR11 va_s0) < va_mul_nat n (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rRbp va_s0) (va_get_reg64 rR13 va_s0) < va_mul_nat n (n `op_Division` 8) /\ va_mul_nat (va_get_reg64 rR14 va_s0) (va_get_reg64 rR11 va_s0) < va_mul_nat n (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rRbx va_s0) (va_get_reg64 rR13 va_s0) < va_mul_nat n (n `op_Division` 8) /\ va_mul_nat (va_get_reg64 rRbp va_s0) (va_get_reg64 rR13 va_s0) < 7 `op_Multiply` (5 `op_Multiply` n `op_Division` 64) /\ va_get_reg64 rRax va_s0 == r1))) (ensures (fun (va_sM, va_fM, hh) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM /\ va_mul_nat h r `op_Modulus` p == hh `op_Modulus` p /\ va_get_reg64 rR10 va_sM `op_Division` 4 `op_Multiply` 4 + va_get_reg64 rR10 va_sM `op_Division` 4 < 18446744073709551616 /\ va_get_reg64 rRax va_sM == 18446744073709551612) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM va_s0)))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_multiply va_b0 va_s0 r1 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok] in let va_qc = va_qcode_Poly1305_multiply va_mods r1 in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_multiply ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let hh = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 62 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in label va_range1 "***** POSTCONDITION NOT MET AT line 88 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 89 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat h r `op_Modulus` p == hh `op_Modulus` p) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 90 column 54 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR10 va_sM `op_Division` 4 `op_Multiply` 4 + va_get_reg64 rR10 va_sM `op_Division` 4 < 18446744073709551616) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 91 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRax va_sM == 18446744073709551612))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok]) va_sM va_s0; let hh = va_g in (va_sM, va_fM, hh) [@ va_qattr] let va_wp_Poly1305_multiply (r1:nat64) (va_s0:va_state) (va_k:(va_state -> int -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in r1 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == r1 + r1 `op_Division` 4 /\ va_mul_nat (va_get_reg64 rRbp va_s0) (va_get_reg64 rR11 va_s0) < 7 `op_Multiply` (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rR14 va_s0) r1 < va_mul_nat n (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rRbx va_s0) (va_get_reg64 rR11 va_s0) < va_mul_nat n (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rRbp va_s0) (va_get_reg64 rR13 va_s0) < va_mul_nat n (n `op_Division` 8) /\ va_mul_nat (va_get_reg64 rR14 va_s0) (va_get_reg64 rR11 va_s0) < va_mul_nat n (n `op_Division` 16) /\ va_mul_nat (va_get_reg64 rRbx va_s0) (va_get_reg64 rR13 va_s0) < va_mul_nat n (n `op_Division` 8) /\ va_mul_nat (va_get_reg64 rRbp va_s0) (va_get_reg64 rR13 va_s0) < 7 `op_Multiply` (5 `op_Multiply` n `op_Division` 64) /\ va_get_reg64 rRax va_s0 == r1) /\ (forall (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_rbp:nat64) (va_x_rax:nat64) (va_x_rdx:nat64) (va_x_efl:Vale.X64.Flags.t) (hh:int) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRax va_x_rax (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 va_s0)))))))) in va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM /\ va_mul_nat h r `op_Modulus` p == hh `op_Modulus` p /\ va_get_reg64 rR10 va_sM `op_Division` 4 `op_Multiply` 4 + va_get_reg64 rR10 va_sM `op_Division` 4 < 18446744073709551616 /\ va_get_reg64 rRax va_sM == 18446744073709551612) ==> va_k va_sM ((hh)))) val va_wpProof_Poly1305_multiply : r1:nat64 -> va_s0:va_state -> va_k:(va_state -> int -> Type0) -> Ghost (va_state & va_fuel & int) (requires (va_t_require va_s0 /\ va_wp_Poly1305_multiply r1 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_multiply ()) ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_multiply r1 va_s0 va_k = let (va_sM, va_f0, hh) = va_lemma_Poly1305_multiply (va_code_Poly1305_multiply ()) va_s0 r1 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM va_s0))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8]) va_sM va_s0; let va_g = (hh) in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_multiply (r1:nat64) : (va_quickCode int (va_code_Poly1305_multiply ())) = (va_QProc (va_code_Poly1305_multiply ()) ([va_Mod_flags; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8]) (va_wp_Poly1305_multiply r1) (va_wpProof_Poly1305_multiply r1)) //-- //-- Poly1305_reduce val va_code_Poly1305_reduce : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_reduce () = (va_Block (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 2)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 3)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 0)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_CNil ())))))))))) val va_codegen_success_Poly1305_reduce : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_reduce () = (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 2)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 3)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_reduce (va_mods:va_mods_t) : (va_quickCode (int) (va_code_Poly1305_reduce ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (hd:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s) + va_mul_nat n (va_get_reg64 rRbx va_s) + va_get_reg64 rR14 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 164 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 166 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 167 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 168 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 169 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 170 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 171 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 172 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 173 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (fun (va_s:va_state) _ -> let (h10:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat n (va_get_reg64 rRbx va_old_s) + va_get_reg64 rR14 va_old_s in let (hh:int) = h10 + va_get_reg64 rRax va_s + va_mul_nat (va_get_reg64 rR10 va_old_s `op_Modulus` 4) (va_mul_nat n n) in let (va_arg27:Prims.int) = hh in let (va_arg26:Prims.int) = va_get_reg64 rRax va_s in let (va_arg25:Prims.int) = h10 in let (va_arg24:Prims.int) = va_get_reg64 rR10 va_old_s in let (va_arg23:Prims.int) = hd in let (va_arg22:Prims.int) = p in let (va_arg21:Prims.int) = n in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 177 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_reduce va_arg21 va_arg22 va_arg23 va_arg24 va_arg25 va_arg26 va_arg27) (va_QEmpty ((hh)))))))))))))) val va_lemma_Poly1305_reduce : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel & int) (requires (va_require_total va_b0 (va_code_Poly1305_reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (hd:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s0) + va_mul_nat n (va_get_reg64 rRbx va_s0) + va_get_reg64 rR14 va_s0 in va_get_reg64 rR10 va_s0 `op_Division` 4 `op_Multiply` 4 + va_get_reg64 rR10 va_s0 `op_Division` 4 < n /\ va_get_reg64 rRax va_s0 == 18446744073709551612))) (ensures (fun (va_sM, va_fM, hh) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (hd:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s0) + va_mul_nat n (va_get_reg64 rRbx va_s0) + va_get_reg64 rR14 va_s0 in hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM /\ hd `op_Modulus` p == hh `op_Modulus` p /\ va_get_reg64 rRbp va_sM < 5) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_reduce va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Poly1305_reduce va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_reduce ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let hh = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 147 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (hd:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s0) + va_mul_nat n (va_get_reg64 rRbx va_s0) + va_get_reg64 rR14 va_s0 in label va_range1 "***** POSTCONDITION NOT MET AT line 160 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 161 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (hd `op_Modulus` p == hh `op_Modulus` p) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 162 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM < 5))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; let hh = va_g in (va_sM, va_fM, hh) [@ va_qattr] let va_wp_Poly1305_reduce (va_s0:va_state) (va_k:(va_state -> int -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (hd:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s0) + va_mul_nat n (va_get_reg64 rRbx va_s0) + va_get_reg64 rR14 va_s0 in va_get_reg64 rR10 va_s0 `op_Division` 4 `op_Multiply` 4 + va_get_reg64 rR10 va_s0 `op_Division` 4 < n /\ va_get_reg64 rRax va_s0 == 18446744073709551612) /\ (forall (va_x_rax:nat64) (va_x_r10:nat64) (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_rbp:nat64) (va_x_efl:Vale.X64.Flags.t) (hh:int) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rRax va_x_rax va_s0))))) in va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (hd:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_mul_nat n n) (va_get_reg64 rR10 va_s0) + va_mul_nat n (va_get_reg64 rRbx va_s0) + va_get_reg64 rR14 va_s0 in hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM /\ hd `op_Modulus` p == hh `op_Modulus` p /\ va_get_reg64 rRbp va_sM < 5) ==> va_k va_sM ((hh)))) val va_wpProof_Poly1305_reduce : va_s0:va_state -> va_k:(va_state -> int -> Type0) -> Ghost (va_state & va_fuel & int) (requires (va_t_require va_s0 /\ va_wp_Poly1305_reduce va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_reduce ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_reduce va_s0 va_k = let (va_sM, va_f0, hh) = va_lemma_Poly1305_reduce (va_code_Poly1305_reduce ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rRax]) va_sM va_s0; let va_g = (hh) in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_reduce () : (va_quickCode int (va_code_Poly1305_reduce ())) = (va_QProc (va_code_Poly1305_reduce ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rRax]) va_wp_Poly1305_reduce va_wpProof_Poly1305_reduce) //-- //-- Poly1305_iteration val va_code_Poly1305_iteration : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_iteration () = (va_Block (va_CCons (va_code_Poly1305_multiply ()) (va_CCons (va_code_Poly1305_reduce ()) (va_CNil ())))) val va_codegen_success_Poly1305_iteration : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_iteration () = (va_pbool_and (va_codegen_success_Poly1305_multiply ()) (va_pbool_and (va_codegen_success_Poly1305_reduce ()) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_iteration (va_mods:va_mods_t) (r1:nat64) : (va_quickCode (int) (va_code_Poly1305_iteration ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s) n + va_get_reg64 rR14 va_s in let (va_arg50:Prims.int) = n `op_Division` 16 in let (va_arg49:Prims.int) = va_get_reg64 rR11 va_s in let (va_arg48:Prims.int) = va_get_reg64 rRbp va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 210 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg48 7 va_arg49 va_arg50) (let (va_arg47:Prims.int) = n `op_Division` 16 in let (va_arg46:Prims.int) = r1 in let (va_arg45:Prims.int) = n in let (va_arg44:Prims.int) = va_get_reg64 rR14 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 211 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg44 va_arg45 va_arg46 va_arg47) (let (va_arg43:Prims.int) = n `op_Division` 16 in let (va_arg42:Prims.int) = va_get_reg64 rR11 va_s in let (va_arg41:Prims.int) = n in let (va_arg40:Prims.int) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 212 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg40 va_arg41 va_arg42 va_arg43) (let (va_arg39:Prims.int) = n `op_Division` 8 in let (va_arg38:Prims.int) = va_get_reg64 rR13 va_s in let (va_arg37:Prims.int) = n in let (va_arg36:Prims.int) = va_get_reg64 rRbp va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 213 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg36 va_arg37 va_arg38 va_arg39) (let (va_arg35:Prims.int) = n `op_Division` 16 in let (va_arg34:Prims.int) = va_get_reg64 rR11 va_s in let (va_arg33:Prims.int) = n in let (va_arg32:Prims.int) = va_get_reg64 rR14 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 214 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg32 va_arg33 va_arg34 va_arg35) (let (va_arg31:Prims.int) = n `op_Division` 8 in let (va_arg30:Prims.int) = va_get_reg64 rR13 va_s in let (va_arg29:Prims.int) = n in let (va_arg28:Prims.int) = va_get_reg64 rRbx va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 215 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg28 va_arg29 va_arg30 va_arg31) (let (va_arg27:Prims.int) = 5 `op_Multiply` n `op_Division` 64 in let (va_arg26:Prims.int) = va_get_reg64 rR13 va_s in let (va_arg25:Prims.int) = va_get_reg64 rRbp va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 216 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mul_strict_upper_bound va_arg25 7 va_arg26 va_arg27) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 218 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_multiply r1) (fun (va_s:va_state) (hd:int) -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 219 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_reduce ()) (fun (va_s:va_state) (hh:int) -> va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 220 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true (fun _ -> va_reveal_eq (`%modp) modp modp) (fun _ -> va_reveal_opaque (`%modp) modp) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 221 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (l_and (hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_s) + va_mul_nat n (va_get_reg64 rRbx va_s) + va_get_reg64 rR14 va_s) (va_mul_nat h r `op_Modulus` p == hh `op_Modulus` p)) (va_QEmpty ((hh))))))))))))))) val va_lemma_Poly1305_iteration : va_b0:va_code -> va_s0:va_state -> r1:nat64 -> Ghost (va_state & va_fuel & int) (requires (va_require_total va_b0 (va_code_Poly1305_iteration ()) va_s0 /\ va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in va_get_reg64 rR11 va_s0 < n `op_Division` 16 /\ r1 < n `op_Division` 16 /\ r1 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == r1 + r1 `op_Division` 4 /\ va_get_reg64 rRbp va_s0 < 7 /\ va_get_reg64 rRax va_s0 == r1))) (ensures (fun (va_sM, va_fM, hh) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM /\ Vale.Poly1305.Spec_s.modp (va_mul_nat h r) == Vale.Poly1305.Spec_s.modp hh /\ va_get_reg64 rRbp va_sM < 5) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_iteration va_b0 va_s0 r1 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Poly1305_iteration va_mods r1 in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_iteration ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let hh = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 180 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in label va_range1 "***** POSTCONDITION NOT MET AT line 200 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 201 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp (va_mul_nat h r) == Vale.Poly1305.Spec_s.modp hh) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 202 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM < 5))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; let hh = va_g in (va_sM, va_fM, hh) [@ va_qattr] let va_wp_Poly1305_iteration (r1:nat64) (va_s0:va_state) (va_k:(va_state -> int -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in va_get_reg64 rR11 va_s0 < n `op_Division` 16 /\ r1 < n `op_Division` 16 /\ r1 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == r1 + r1 `op_Division` 4 /\ va_get_reg64 rRbp va_s0 < 7 /\ va_get_reg64 rRax va_s0 == r1) /\ (forall (va_x_rax:nat64) (va_x_rdx:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_rbp:nat64) (va_x_efl:Vale.X64.Flags.t) (hh:int) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRax va_x_rax va_s0)))))))) in va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r:(va_int_range 0 340282366920938463463374607431768211455)) = va_mul_nat r1 n + va_get_reg64 rR11 va_s0 in let (h:(va_int_range 0 6277101735386680763835789423207666416102355444464034512895)) = va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s0) n + va_get_reg64 rR14 va_s0 in hh == va_mul_nat (va_mul_nat n n) (va_get_reg64 rRbp va_sM) + va_mul_nat n (va_get_reg64 rRbx va_sM) + va_get_reg64 rR14 va_sM /\ Vale.Poly1305.Spec_s.modp (va_mul_nat h r) == Vale.Poly1305.Spec_s.modp hh /\ va_get_reg64 rRbp va_sM < 5) ==> va_k va_sM ((hh)))) val va_wpProof_Poly1305_iteration : r1:nat64 -> va_s0:va_state -> va_k:(va_state -> int -> Type0) -> Ghost (va_state & va_fuel & int) (requires (va_t_require va_s0 /\ va_wp_Poly1305_iteration r1 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_iteration ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_iteration r1 va_s0 va_k = let (va_sM, va_f0, hh) = va_lemma_Poly1305_iteration (va_code_Poly1305_iteration ()) va_s0 r1 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) va_sM va_s0; let va_g = (hh) in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_iteration (r1:nat64) : (va_quickCode int (va_code_Poly1305_iteration ())) = (va_QProc (va_code_Poly1305_iteration ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax]) (va_wp_Poly1305_iteration r1) (va_wpProof_Poly1305_iteration r1)) //-- //-- Poly1305_blocks_body0 val va_code_Poly1305_blocks_body0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_blocks_body0 () = (va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Public)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Public)) (va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRsi) (va_const_opr64 16)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Poly1305_iteration ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Sub64 (va_op_dst_opr64_reg64 rR15) (va_const_opr64 1)) (va_CNil ()))))))))))) val va_codegen_success_Poly1305_blocks_body0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_blocks_body0 () = (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Public)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Public)) (va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRsi) (va_const_opr64 16)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Poly1305_iteration ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Sub64 (va_op_dst_opr64_reg64 rR15) (va_const_opr64 1)) (va_ttrue ())))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_blocks_body0 (va_mods:va_mods_t) (va_old:va_state) (va_in_ctx_b:buffer64) (va_in_h_in:int) (va_in_inp_b:buffer64) (va_in_length:int) (va_in_n:(va_int_range 18446744073709551616 18446744073709551616)) (va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) (va_in_r:int) (va_in_h:int) (va_in_word_index:nat) : (va_quickCode (int & nat) (va_code_Poly1305_blocks_body0 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (ctx_b:buffer64) = va_in_ctx_b in let (h_in:int) = va_in_h_in in let (inp_b:buffer64) = va_in_inp_b in let (length:int) = va_in_length in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = va_in_n in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_in_p in let (r:int) = va_in_r in let (h:int) = va_in_h in let (word_index:nat) = va_in_word_index in let (nn:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (hp:int) = h in let (h:int) = h + va_mul_nat (va_mul_nat nn nn) (va_get_reg64 rRcx va_s) + va_mul_nat nn (Vale.X64.Decls.buffer64_read inp_b (word_index + 1) (va_get_mem_heaplet 0 va_s)) + Vale.X64.Decls.buffer64_read inp_b word_index (va_get_mem_heaplet 0 va_s) in let (hq:int) = h in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 353 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inp_b word_index Public) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 353 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Public)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 354 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inp_b (word_index + 1) Public) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 354 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Public)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 355 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_AddLea64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRsi) (va_const_opr64 16)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 356 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 358 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (hq == va_mul_nat (va_get_reg64 rRbp va_s) (va_mul_nat nn nn) + va_mul_nat (va_get_reg64 rRbx va_s) nn + va_get_reg64 rR14 va_s) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 360 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_iteration (va_get_reg64 rR12 va_s)) (fun (va_s:va_state) (h:int) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 362 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR12)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 363 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64 (va_op_dst_opr64_reg64 rR15) (va_const_opr64 1)) (fun (va_s:va_state) _ -> let (word_index:nat) = word_index + 2 in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 366 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp h_in) (va_mul_nat (va_get_reg64 rRcx va_s) (va_mul_nat nn nn)) r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b) word_index) (let (va_arg50:Prims.int) = word_index in let (va_arg49:(FStar.Seq.Base.seq Vale.X64.Memory.nat64)) = Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b in let (va_arg48:Prims.int) = r in let (va_arg47:Prims.int) = va_mul_nat (va_get_reg64 rRcx va_s) (va_mul_nat nn nn) in let (va_arg46:Prims.int) = Vale.Poly1305.Spec_s.modp h_in in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 368 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Util.reveal_poly1305_heap_blocks va_arg46 va_arg47 va_arg48 va_arg49 va_arg50) (let (va_arg45:Prims.int) = word_index - 2 in let (va_arg44:(FStar.Seq.Base.seq Vale.X64.Memory.nat64)) = Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b in let (va_arg43:Prims.int) = r in let (va_arg42:Prims.int) = va_mul_nat (va_get_reg64 rRcx va_s) (va_mul_nat nn nn) in let (va_arg41:Prims.int) = Vale.Poly1305.Spec_s.modp h_in in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 369 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Util.reveal_poly1305_heap_blocks va_arg41 va_arg42 va_arg43 va_arg44 va_arg45) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 370 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true (fun _ -> va_reveal_eq (`%modp) modp modp) (fun _ -> va_reveal_opaque (`%modp) modp) (let (va_arg40:Prims.int) = r in let (va_arg39:Prims.int) = hq - hp in let (va_arg38:Prims.int) = hp in let (va_arg37:Prims.pos) = p in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 371 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_demod va_arg37 va_arg38 va_arg39 va_arg40) (va_QEmpty (())))))) (va_QEmpty ((h, word_index))))))))))))))) val va_lemma_Poly1305_blocks_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state -> va_in_ctx_b:buffer64 -> va_in_h_in:int -> va_in_inp_b:buffer64 -> va_in_length:int -> va_in_n:(va_int_range 18446744073709551616 18446744073709551616) -> va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819) -> va_in_r:int -> va_in_h:int -> va_in_word_index:nat -> Ghost (va_state & va_fuel & int & nat) (requires (va_require_total va_b0 (va_code_Poly1305_blocks_body0 ()) va_s0 /\ va_get_ok va_s0 /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_s0) va_in_n + va_get_reg64 rR11 va_s0 /\ va_in_h == va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_s0) pow2_64 + va_get_reg64 rR14 va_s0 /\ va_get_reg64 rR11 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == va_get_reg64 rR12 va_s0 + va_get_reg64 rR12 va_s0 `op_Division` 4 /\ va_get_reg64 rRbp va_s0 < 5 /\ va_get_reg64 rRax va_s0 == va_get_reg64 rR12 va_s0 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rR15 va_s0 == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_s0 =!= 0 ==> 8 `op_Multiply` (va_in_word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_s0 + 8 `op_Multiply` va_in_word_index == va_in_length /\ va_get_reg64 rRsi va_s0 + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_s0) + 8 `op_Multiply` va_in_word_index /\ va_get_reg64 rR15 va_s0 `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_s0 < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) va_in_ctx_b 24 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_s0) Public /\ va_get_reg64 rRdi va_s0 == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_s0 == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_s0 - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp va_in_h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_s0) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s0) va_in_inp_b) va_in_word_index /\ va_get_mem_heaplet 1 va_s0 == va_get_mem_heaplet 1 va_old /\ va_get_reg64 rR15 va_s0 =!= 0)) (ensures (fun (va_sM, va_fM, h, word_index) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_sM) va_in_n + va_get_reg64 rR11 va_sM /\ h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM /\ va_get_reg64 rR11 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4 /\ va_get_reg64 rRbp va_sM < 5 /\ va_get_reg64 rRax va_sM == va_get_reg64 rR12 va_sM /\ va_get_reg64 rRsi va_sM + 16 `op_Multiply` va_get_reg64 rR15 va_sM == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_sM =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_sM + 8 `op_Multiply` word_index == va_in_length /\ va_get_reg64 rRsi va_sM + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_sM) + 8 `op_Multiply` word_index /\ va_get_reg64 rR15 va_sM `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_sM < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) va_in_ctx_b 24 (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_sM) Public /\ va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_sM - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) va_in_inp_b) word_index /\ va_get_mem_heaplet 1 va_sM == va_get_mem_heaplet 1 va_old /\ precedes_wrap (va_get_reg64 rR15 va_sM) (va_get_reg64 rR15 va_s0) /\ va_state_eq va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_ok va_sM (va_update_flags va_sM va_s0)))))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_blocks_body0 va_b0 va_s0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index = let va_old = va_expand_state va_old in let (va_mods:va_mods_t) = [va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags] in let va_qc = va_qcode_Poly1305_blocks_body0 va_mods va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_blocks_body0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let (h, word_index) = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 224 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 317 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_n == pow2_64) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 318 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 319 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 320 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_r == va_mul_nat (va_get_reg64 rR12 va_sM) va_in_n + va_get_reg64 rR11 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 321 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 322 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR11 va_sM < va_in_n `op_Division` 16) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 323 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR12 va_sM < va_in_n `op_Division` 16) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR12 va_sM `op_Modulus` 4 == 0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 325 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 326 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM < 5) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 327 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRax va_sM == va_get_reg64 rR12 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 328 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_sM + 16 `op_Multiply` va_get_reg64 rR15 va_sM == va_get_reg64 rRsi va_old + va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_old + va_in_length < pow2_64) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_length == va_get_reg64 rRdx va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 332 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR15 va_sM =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 333 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (16 `op_Multiply` va_get_reg64 rR15 va_sM + 8 `op_Multiply` word_index == va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 334 column 79 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_sM + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_sM) + 8 `op_Multiply` word_index) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 336 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR15 va_sM `op_Multiply` 16 <= va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 337 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRcx va_sM < 2) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 338 column 70 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) va_in_ctx_b 24 (va_get_mem_layout va_sM) Public) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 339 column 81 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_sM) Public) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 340 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 341 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 342 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ((va_get_reg64 rRsi va_sM - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 343 column 120 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) va_in_inp_b) word_index) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 344 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_mem_heaplet 1 va_sM == va_get_mem_heaplet 1 va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 345 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (precedes_wrap (va_get_reg64 rR15 va_sM) (va_get_reg64 rR15 va_s0))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) va_sM va_s0; let (h, word_index) = va_g in (va_sM, va_fM, h, word_index) [@ va_qattr] let va_wp_Poly1305_blocks_body0 (va_old:va_state) (va_in_ctx_b:buffer64) (va_in_h_in:int) (va_in_inp_b:buffer64) (va_in_length:int) (va_in_n:(va_int_range 18446744073709551616 18446744073709551616)) (va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) (va_in_r:int) (va_in_h:int) (va_in_word_index:nat) (va_s0:va_state) (va_k:(va_state -> (int & nat) -> Type0)) : Type0 = (va_get_ok va_s0 /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_s0) va_in_n + va_get_reg64 rR11 va_s0 /\ va_in_h == va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_s0) pow2_64 + va_get_reg64 rR14 va_s0 /\ va_get_reg64 rR11 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == va_get_reg64 rR12 va_s0 + va_get_reg64 rR12 va_s0 `op_Division` 4 /\ va_get_reg64 rRbp va_s0 < 5 /\ va_get_reg64 rRax va_s0 == va_get_reg64 rR12 va_s0 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rR15 va_s0 == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_s0 =!= 0 ==> 8 `op_Multiply` (va_in_word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_s0 + 8 `op_Multiply` va_in_word_index == va_in_length /\ va_get_reg64 rRsi va_s0 + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_s0) + 8 `op_Multiply` va_in_word_index /\ va_get_reg64 rR15 va_s0 `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_s0 < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) va_in_ctx_b 24 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_s0) Public /\ va_get_reg64 rRdi va_s0 == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_s0 == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_s0 - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp va_in_h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_s0) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s0) va_in_inp_b) va_in_word_index /\ va_get_mem_heaplet 1 va_s0 == va_get_mem_heaplet 1 va_old /\ va_get_reg64 rR15 va_s0 =!= 0 /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r14:nat64) (va_x_r15:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_rax:nat64) (va_x_rbp:nat64) (va_x_rbx:nat64) (va_x_rdx:nat64) (va_x_rsi:nat64) (h:int) (word_index:nat) . let va_sM = va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRax va_x_rax (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR10 va_x_r10 (va_upd_ok va_x_ok (va_upd_flags va_x_efl va_s0))))))))))) in va_get_ok va_sM /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_sM) va_in_n + va_get_reg64 rR11 va_sM /\ h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM /\ va_get_reg64 rR11 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4 /\ va_get_reg64 rRbp va_sM < 5 /\ va_get_reg64 rRax va_sM == va_get_reg64 rR12 va_sM /\ va_get_reg64 rRsi va_sM + 16 `op_Multiply` va_get_reg64 rR15 va_sM == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_sM =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_sM + 8 `op_Multiply` word_index == va_in_length /\ va_get_reg64 rRsi va_sM + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_sM) + 8 `op_Multiply` word_index /\ va_get_reg64 rR15 va_sM `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_sM < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) va_in_ctx_b 24 (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_sM) Public /\ va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_sM - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) va_in_inp_b) word_index /\ va_get_mem_heaplet 1 va_sM == va_get_mem_heaplet 1 va_old /\ precedes_wrap (va_get_reg64 rR15 va_sM) (va_get_reg64 rR15 va_s0) ==> va_k va_sM ((h, word_index)))) val va_wpProof_Poly1305_blocks_body0 : va_old:va_state -> va_in_ctx_b:buffer64 -> va_in_h_in:int -> va_in_inp_b:buffer64 -> va_in_length:int -> va_in_n:(va_int_range 18446744073709551616 18446744073709551616) -> va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819) -> va_in_r:int -> va_in_h:int -> va_in_word_index:nat -> va_s0:va_state -> va_k:(va_state -> (int & nat) -> Type0) -> Ghost (va_state & va_fuel & (int & nat)) (requires (va_t_require va_s0 /\ va_wp_Poly1305_blocks_body0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_blocks_body0 ()) ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_blocks_body0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index va_s0 va_k = let (va_sM, va_f0, h, word_index) = va_lemma_Poly1305_blocks_body0 (va_code_Poly1305_blocks_body0 ()) va_s0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_ok va_sM (va_update_flags va_sM va_s0))))))))))))); va_lemma_norm_mods ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) va_sM va_s0; let va_g = (h, word_index) in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_blocks_body0 (va_old:va_state) (va_in_ctx_b:buffer64) (va_in_h_in:int) (va_in_inp_b:buffer64) (va_in_length:int) (va_in_n:(va_int_range 18446744073709551616 18446744073709551616)) (va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) (va_in_r:int) (va_in_h:int) (va_in_word_index:nat) : (va_quickCode (int & nat) (va_code_Poly1305_blocks_body0 ())) = (va_QProc (va_code_Poly1305_blocks_body0 ()) ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) (va_wp_Poly1305_blocks_body0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index) (va_wpProof_Poly1305_blocks_body0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index)) //-- //-- Poly1305_blocks_while0 val va_code_Poly1305_blocks_while0 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_blocks_while0 () = (va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg64 rR15) (va_const_cmp 0)) (va_Block (va_CCons (va_code_Poly1305_blocks_body0 ()) (va_CNil ())))) (va_CNil ()))) val va_codegen_success_Poly1305_blocks_while0 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_blocks_while0 () = (va_pbool_and (va_codegen_success_Poly1305_blocks_body0 ()) (va_ttrue ())) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_blocks_while0 (va_mods:va_mods_t) (va_old:va_state) (va_in_ctx_b:buffer64) (va_in_h_in:int) (va_in_inp_b:buffer64) (va_in_length:int) (va_in_n:(va_int_range 18446744073709551616 18446744073709551616)) (va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) (va_in_r:int) (va_in_h:int) (va_in_word_index:nat) : (va_quickCode (int & nat) (va_code_Poly1305_blocks_while0 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (ctx_b:buffer64) = va_in_ctx_b in let (h_in:int) = va_in_h_in in let (inp_b:buffer64) = va_in_inp_b in let (length:int) = va_in_length in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = va_in_n in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_in_p in let (r:int) = va_in_r in let (h:int) = va_in_h in let (word_index:nat) = va_in_word_index in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 224 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_qWhile va_mods (Cmp_ne (va_op_cmp_reg64 rR15) (va_const_cmp 0)) (fun va_g -> let (h:int) = let (h, word_index) = va_g in h in let (word_index:nat) = let (h, word_index) = va_g in word_index in qblock va_mods (fun (va_s:va_state) -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 224 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_blocks_body0 va_old ctx_b h_in inp_b length n p r h word_index) (fun (va_s:va_state) va_g -> let (h, word_index) = va_g in va_QEmpty ((h, word_index))))) (fun (va_s:va_state) va_g -> let (h:int) = let (h, word_index) = va_g in h in let (word_index:nat) = let (h, word_index) = va_g in word_index in va_get_ok va_s /\ n == pow2_64 /\ va_mul_nat n n == va_mul_nat pow2_64 pow2_64 /\ p == va_mul_nat n n `op_Multiply` 4 - 5 /\ r == va_mul_nat (va_get_reg64 rR12 va_s) n + va_get_reg64 rR11 va_s /\ h == va_mul_nat (va_get_reg64 rRbp va_s) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_s) pow2_64 + va_get_reg64 rR14 va_s /\ va_get_reg64 rR11 va_s < n `op_Division` 16 /\ va_get_reg64 rR12 va_s < n `op_Division` 16 /\ va_get_reg64 rR12 va_s `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s == va_get_reg64 rR12 va_s + va_get_reg64 rR12 va_s `op_Division` 4 /\ va_get_reg64 rRbp va_s < 5 /\ va_get_reg64 rRax va_s == va_get_reg64 rR12 va_s /\ va_get_reg64 rRsi va_s + 16 `op_Multiply` va_get_reg64 rR15 va_s == va_get_reg64 rRsi va_old + length /\ va_get_reg64 rRsi va_old + length < pow2_64 /\ length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_s =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_s + 8 `op_Multiply` word_index == length /\ va_get_reg64 rRsi va_s + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 inp_b (va_get_mem_heaplet 0 va_s) + 8 `op_Multiply` word_index /\ va_get_reg64 rR15 va_s `op_Multiply` 16 <= length /\ va_get_reg64 rRcx va_s < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s) (va_get_reg64 rRdi va_s) ctx_b 24 (va_get_mem_layout va_s) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s) (va_get_reg64 rRsi va_old) inp_b (length `op_Division` 8) (va_get_mem_layout va_s) Public /\ va_get_reg64 rRdi va_s == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_s == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_s - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp h_in) (va_mul_nat (va_get_reg64 rRcx va_s) (va_mul_nat n n)) r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b) word_index /\ va_get_mem_heaplet 1 va_s == va_get_mem_heaplet 1 va_old) (fun (va_s:va_state) va_g -> let (h:int) = let (h, word_index) = va_g in h in let (word_index:nat) = let (h, word_index) = va_g in word_index in va_get_reg64 rR15 va_s) ((h, word_index))) (fun (va_s:va_state) va_g -> let (h:int) = let (h, word_index) = va_g in h in let (word_index:nat) = let (h, word_index) = va_g in word_index in let va_g = (h, word_index) in let ((h:int), (word_index:nat)) = va_g in va_QEmpty ((h, word_index))))) val va_lemma_Poly1305_blocks_while0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state -> va_in_ctx_b:buffer64 -> va_in_h_in:int -> va_in_inp_b:buffer64 -> va_in_length:int -> va_in_n:(va_int_range 18446744073709551616 18446744073709551616) -> va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819) -> va_in_r:int -> va_in_h:int -> va_in_word_index:nat -> Ghost (va_state & va_fuel & int & nat) (requires (va_require_total va_b0 (va_code_Poly1305_blocks_while0 ()) va_s0 /\ va_get_ok va_s0 /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_s0) va_in_n + va_get_reg64 rR11 va_s0 /\ va_in_h == va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_s0) pow2_64 + va_get_reg64 rR14 va_s0 /\ va_get_reg64 rR11 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == va_get_reg64 rR12 va_s0 + va_get_reg64 rR12 va_s0 `op_Division` 4 /\ va_get_reg64 rRbp va_s0 < 5 /\ va_get_reg64 rRax va_s0 == va_get_reg64 rR12 va_s0 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rR15 va_s0 == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_s0 =!= 0 ==> 8 `op_Multiply` (va_in_word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_s0 + 8 `op_Multiply` va_in_word_index == va_in_length /\ va_get_reg64 rRsi va_s0 + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_s0) + 8 `op_Multiply` va_in_word_index /\ va_get_reg64 rR15 va_s0 `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_s0 < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) va_in_ctx_b 24 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_s0) Public /\ va_get_reg64 rRdi va_s0 == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_s0 == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_s0 - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp va_in_h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_s0) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s0) va_in_inp_b) va_in_word_index /\ va_get_mem_heaplet 1 va_s0 == va_get_mem_heaplet 1 va_old)) (ensures (fun (va_sM, va_fM, h, word_index) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_sM) va_in_n + va_get_reg64 rR11 va_sM /\ h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM /\ va_get_reg64 rR11 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4 /\ va_get_reg64 rRbp va_sM < 5 /\ va_get_reg64 rRax va_sM == va_get_reg64 rR12 va_sM /\ va_get_reg64 rRsi va_sM + 16 `op_Multiply` va_get_reg64 rR15 va_sM == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_sM =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_sM + 8 `op_Multiply` word_index == va_in_length /\ va_get_reg64 rRsi va_sM + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_sM) + 8 `op_Multiply` word_index /\ va_get_reg64 rR15 va_sM `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_sM < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) va_in_ctx_b 24 (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_sM) Public /\ va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_sM - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) va_in_inp_b) word_index /\ va_get_mem_heaplet 1 va_sM == va_get_mem_heaplet 1 va_old /\ ~(va_get_reg64 rR15 va_sM =!= 0) /\ va_state_eq va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_ok va_sM (va_update_flags va_sM va_s0)))))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_blocks_while0 va_b0 va_s0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index = let va_old = va_expand_state va_old in let (va_mods:va_mods_t) = [va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags] in let va_qc = va_qcode_Poly1305_blocks_while0 va_mods va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_blocks_while0 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let (h, word_index) = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 224 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 317 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_n == pow2_64) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 318 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 319 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 320 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_r == va_mul_nat (va_get_reg64 rR12 va_sM) va_in_n + va_get_reg64 rR11 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 321 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 322 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR11 va_sM < va_in_n `op_Division` 16) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 323 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR12 va_sM < va_in_n `op_Division` 16) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 324 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR12 va_sM `op_Modulus` 4 == 0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 325 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 326 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM < 5) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 327 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRax va_sM == va_get_reg64 rR12 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 328 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_sM + 16 `op_Multiply` va_get_reg64 rR15 va_sM == va_get_reg64 rRsi va_old + va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 329 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_old + va_in_length < pow2_64) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 330 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_in_length == va_get_reg64 rRdx va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 332 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR15 va_sM =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 333 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (16 `op_Multiply` va_get_reg64 rR15 va_sM + 8 `op_Multiply` word_index == va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 334 column 79 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_sM + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_sM) + 8 `op_Multiply` word_index) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 336 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR15 va_sM `op_Multiply` 16 <= va_in_length) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 337 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRcx va_sM < 2) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 338 column 70 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) va_in_ctx_b 24 (va_get_mem_layout va_sM) Public) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 339 column 81 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_sM) Public) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 340 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 341 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 342 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ((va_get_reg64 rRsi va_sM - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 343 column 120 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) va_in_inp_b) word_index) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 344 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_mem_heaplet 1 va_sM == va_get_mem_heaplet 1 va_old) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 224 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (~(va_get_reg64 rR15 va_sM =!= 0))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) va_sM va_s0; let (h, word_index) = va_g in (va_sM, va_fM, h, word_index) [@ va_qattr] let va_wp_Poly1305_blocks_while0 (va_old:va_state) (va_in_ctx_b:buffer64) (va_in_h_in:int) (va_in_inp_b:buffer64) (va_in_length:int) (va_in_n:(va_int_range 18446744073709551616 18446744073709551616)) (va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) (va_in_r:int) (va_in_h:int) (va_in_word_index:nat) (va_s0:va_state) (va_k:(va_state -> (int & nat) -> Type0)) : Type0 = (va_get_ok va_s0 /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_s0) va_in_n + va_get_reg64 rR11 va_s0 /\ va_in_h == va_mul_nat (va_get_reg64 rRbp va_s0) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_s0) pow2_64 + va_get_reg64 rR14 va_s0 /\ va_get_reg64 rR11 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_s0 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == va_get_reg64 rR12 va_s0 + va_get_reg64 rR12 va_s0 `op_Division` 4 /\ va_get_reg64 rRbp va_s0 < 5 /\ va_get_reg64 rRax va_s0 == va_get_reg64 rR12 va_s0 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rR15 va_s0 == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_s0 =!= 0 ==> 8 `op_Multiply` (va_in_word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_s0 + 8 `op_Multiply` va_in_word_index == va_in_length /\ va_get_reg64 rRsi va_s0 + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_s0) + 8 `op_Multiply` va_in_word_index /\ va_get_reg64 rR15 va_s0 `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_s0 < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) va_in_ctx_b 24 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_s0) Public /\ va_get_reg64 rRdi va_s0 == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_s0 == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_s0 - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp va_in_h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_s0) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s0) va_in_inp_b) va_in_word_index /\ va_get_mem_heaplet 1 va_s0 == va_get_mem_heaplet 1 va_old /\ (forall (va_x_efl:Vale.X64.Flags.t) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r14:nat64) (va_x_r15:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_rax:nat64) (va_x_rbp:nat64) (va_x_rbx:nat64) (va_x_rdx:nat64) (va_x_rsi:nat64) (h:int) (word_index:nat) . let va_sM = va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRax va_x_rax (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR10 va_x_r10 (va_upd_ok va_x_ok (va_upd_flags va_x_efl va_s0))))))))))) in va_get_ok va_sM /\ va_in_n == pow2_64 /\ va_mul_nat va_in_n va_in_n == va_mul_nat pow2_64 pow2_64 /\ va_in_p == va_mul_nat va_in_n va_in_n `op_Multiply` 4 - 5 /\ va_in_r == va_mul_nat (va_get_reg64 rR12 va_sM) va_in_n + va_get_reg64 rR11 va_sM /\ h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM /\ va_get_reg64 rR11 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM < va_in_n `op_Division` 16 /\ va_get_reg64 rR12 va_sM `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4 /\ va_get_reg64 rRbp va_sM < 5 /\ va_get_reg64 rRax va_sM == va_get_reg64 rR12 va_sM /\ va_get_reg64 rRsi va_sM + 16 `op_Multiply` va_get_reg64 rR15 va_sM == va_get_reg64 rRsi va_old + va_in_length /\ va_get_reg64 rRsi va_old + va_in_length < pow2_64 /\ va_in_length == va_get_reg64 rRdx va_old /\ (va_get_reg64 rR15 va_sM =!= 0 ==> 8 `op_Multiply` (word_index + 1) <= va_in_length) /\ 16 `op_Multiply` va_get_reg64 rR15 va_sM + 8 `op_Multiply` word_index == va_in_length /\ va_get_reg64 rRsi va_sM + 0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint64 va_in_inp_b (va_get_mem_heaplet 0 va_sM) + 8 `op_Multiply` word_index /\ va_get_reg64 rR15 va_sM `op_Multiply` 16 <= va_in_length /\ va_get_reg64 rRcx va_sM < 2 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) va_in_ctx_b 24 (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_old) va_in_inp_b (va_in_length `op_Division` 8) (va_get_mem_layout va_sM) Public /\ va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_old /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_old /\ (va_get_reg64 rRsi va_sM - va_get_reg64 rRsi va_old) `op_Modulus` 16 == 0 /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp va_in_h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat va_in_n va_in_n)) va_in_r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) va_in_inp_b) word_index /\ va_get_mem_heaplet 1 va_sM == va_get_mem_heaplet 1 va_old /\ ~(va_get_reg64 rR15 va_sM =!= 0) ==> va_k va_sM ((h, word_index)))) val va_wpProof_Poly1305_blocks_while0 : va_old:va_state -> va_in_ctx_b:buffer64 -> va_in_h_in:int -> va_in_inp_b:buffer64 -> va_in_length:int -> va_in_n:(va_int_range 18446744073709551616 18446744073709551616) -> va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819) -> va_in_r:int -> va_in_h:int -> va_in_word_index:nat -> va_s0:va_state -> va_k:(va_state -> (int & nat) -> Type0) -> Ghost (va_state & va_fuel & (int & nat)) (requires (va_t_require va_s0 /\ va_wp_Poly1305_blocks_while0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_blocks_while0 ()) ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_blocks_while0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index va_s0 va_k = let (va_sM, va_f0, h, word_index) = va_lemma_Poly1305_blocks_while0 (va_code_Poly1305_blocks_while0 ()) va_s0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_ok va_sM (va_update_flags va_sM va_s0))))))))))))); va_lemma_norm_mods ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) va_sM va_s0; let va_g = (h, word_index) in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_blocks_while0 (va_old:va_state) (va_in_ctx_b:buffer64) (va_in_h_in:int) (va_in_inp_b:buffer64) (va_in_length:int) (va_in_n:(va_int_range 18446744073709551616 18446744073709551616)) (va_in_p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) (va_in_r:int) (va_in_h:int) (va_in_word_index:nat) : (va_quickCode (int & nat) (va_code_Poly1305_blocks_while0 ())) = (va_QProc (va_code_Poly1305_blocks_while0 ()) ([va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRbx; va_Mod_reg64 rRbp; va_Mod_reg64 rRax; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_ok; va_Mod_flags]) (va_wp_Poly1305_blocks_while0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index) (va_wpProof_Poly1305_blocks_while0 va_old va_in_ctx_b va_in_h_in va_in_inp_b va_in_length va_in_n va_in_p va_in_r va_in_h va_in_word_index)) //-- //-- Poly1305_blocks val va_code_Poly1305_blocks : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_blocks () = (va_Block (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 4)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR15) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRdi) 32 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR14) (va_op_reg_opr64_reg64 rRdi) 0 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRdi) 8 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRdi) 16 Public) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR13) (va_const_shift_amt64 2)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Poly1305_blocks_while0 ()) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 0 Public) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 8 Public) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbp) 16 Public) (va_CNil ()))))))))))))))))) val va_codegen_success_Poly1305_blocks : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_blocks () = (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 4)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR15) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRdi) 32 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR14) (va_op_reg_opr64_reg64 rRdi) 0 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRdi) 8 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRdi) 16 Public) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR13) (va_const_shift_amt64 2)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Add64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Poly1305_blocks_while0 ()) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 0 Public) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 8 Public) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbp) 16 Public) (va_ttrue ())))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_blocks (va_mods:va_mods_t) (r:int) (h_in:int) (ctx_b:buffer64) (inp_b:buffer64) : (va_quickCode (int) (va_code_Poly1305_blocks ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 285 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (let (length:int) = va_get_reg64 rRdx va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rRdx) (va_const_shift_amt64 4)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 292 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR15) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 294 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public ctx_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 295 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRdi) 32 Public ctx_b 4) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 297 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR14) (va_op_reg_opr64_reg64 rRdi) 0 Public ctx_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 298 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRdi) 8 Public ctx_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 299 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRdi) 16 Public ctx_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 301 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rR13)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 302 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR13) (va_const_shift_amt64 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 303 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR12)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 304 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rR12)) (fun (va_s:va_state) _ -> let (h:int) = h_in in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 307 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp h_in) (va_mul_nat (va_get_reg64 rRcx va_s) (va_mul_nat n n)) r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b) 0) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 309 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true (fun _ -> va_reveal_eq (`%modp) modp modp) (fun _ -> va_reveal_opaque (`%modp) modp) (let (va_arg40:(FStar.Seq.Base.seq Vale.X64.Memory.nat64)) = Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_s) inp_b in let (va_arg39:Prims.int) = r in let (va_arg38:Prims.int) = va_mul_nat (va_get_reg64 rRcx va_s) (va_mul_nat n n) in let (va_arg37:Prims.int) = Vale.Poly1305.Spec_s.modp h_in in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 310 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Util.reveal_poly1305_heap_blocks va_arg37 va_arg38 va_arg39 va_arg40 0) (va_QEmpty (())))) (let (word_index:nat) = 0 in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 315 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_blocks_while0 va_old_s ctx_b h_in inp_b length n p r h word_index) (fun (va_s:va_state) va_g -> let (h, word_index) = va_g in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 374 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 0 Public ctx_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 375 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 8 Public ctx_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 376 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbp) 16 Public ctx_b 2) (va_QEmpty ((h))))))))))))))))))))) val va_lemma_Poly1305_blocks : va_b0:va_code -> va_s0:va_state -> r:int -> h_in:int -> ctx_b:buffer64 -> inp_b:buffer64 -> Ghost (va_state & va_fuel & int) (requires (va_require_total va_b0 (va_code_Poly1305_blocks ()) va_s0 /\ va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in va_get_reg64 rRdx va_s0 `op_Modulus` 16 == 0 /\ va_get_reg64 rRsi va_s0 + va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) ctx_b 24 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inp_b (va_get_reg64 rRdx va_s0 `op_Division` 8) (va_get_mem_layout va_s0) Public /\ (let h0_in = Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_s0) in let h1_in = Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_s0) in let h2_in = Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_s0) in let r0_in = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_s0) in let r1_in = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_s0) in h_in == va_mul_nat h2_in (va_mul_nat n n) + va_mul_nat h1_in n + h0_in /\ r == va_mul_nat r1_in n + r0_in /\ r0_in < n `op_Division` 16 /\ r1_in < n `op_Division` 16 /\ r1_in `op_Modulus` 4 == 0 /\ h2_in < 5 /\ va_get_reg64 rRcx va_s0 < 2)))) (ensures (fun (va_sM, va_fM, h) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in va_get_reg64 rRbp va_sM < 5 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) ctx_b 24 (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_s0) inp_b (va_get_reg64 rRdx va_s0 `op_Division` 8) (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.modifies_buffer_specific ctx_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) 0 2 /\ va_get_reg64 rR14 va_sM == Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rRbx va_sM == Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rRbp va_sM == Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rR11 va_sM == Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rR12 va_sM == Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4 /\ va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0 + va_get_reg64 rRdx va_s0 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0 /\ (let r0_in = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_sM) in let r1_in = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_sM) in h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat n n)) r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) inp_b) (va_get_reg64 rRdx va_s0 `op_Division` 8))) /\ va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_flags va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_blocks va_b0 va_s0 r h_in ctx_b inp_b = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Poly1305_blocks va_mods r h_in ctx_b inp_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_blocks ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let h = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 224 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in label va_range1 "***** POSTCONDITION NOT MET AT line 264 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM < 5) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 265 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) ctx_b 24 (va_get_mem_layout va_sM) Public) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 266 column 79 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_s0) inp_b (va_get_reg64 rRdx va_s0 `op_Division` 8) (va_get_mem_layout va_sM) Public) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 267 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.X64.Decls.modifies_buffer_specific ctx_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) 0 2) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 268 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR14 va_sM == Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 269 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbx va_sM == Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 270 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM == Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 271 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR11 va_sM == Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 272 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR12 va_sM == Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 273 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 274 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0 + va_get_reg64 rRdx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 277 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 278 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 280 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (let r0_in = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 281 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (let r1_in = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 282 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 283 column 118 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat n n)) r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) inp_b) (va_get_reg64 rRdx va_s0 `op_Division` 8)))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_ok; va_Mod_mem]) va_sM va_s0; let h = va_g in (va_sM, va_fM, h) [@ va_qattr] let va_wp_Poly1305_blocks (r:int) (h_in:int) (ctx_b:buffer64) (inp_b:buffer64) (va_s0:va_state) (va_k:(va_state -> int -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in va_get_reg64 rRdx va_s0 `op_Modulus` 16 == 0 /\ va_get_reg64 rRsi va_s0 + va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) ctx_b 24 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inp_b (va_get_reg64 rRdx va_s0 `op_Division` 8) (va_get_mem_layout va_s0) Public /\ (let h0_in = Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_s0) in let h1_in = Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_s0) in let h2_in = Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_s0) in let r0_in = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_s0) in let r1_in = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_s0) in h_in == va_mul_nat h2_in (va_mul_nat n n) + va_mul_nat h1_in n + h0_in /\ r == va_mul_nat r1_in n + r0_in /\ r0_in < n `op_Division` 16 /\ r1_in < n `op_Division` 16 /\ r1_in `op_Modulus` 4 == 0 /\ h2_in < 5 /\ va_get_reg64 rRcx va_s0 < 2)) /\ (forall (va_x_mem:vale_heap) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_rbp:nat64) (va_x_rax:nat64) (va_x_r15:nat64) (va_x_efl:Vale.X64.Flags.t) (va_x_heap1:vale_heap) (h:int) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_flags va_x_efl (va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rRax va_x_rax (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_mem va_x_mem va_s0))))))))))))))) in va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = pow2_64 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in va_get_reg64 rRbp va_sM < 5 /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdi va_sM) ctx_b 24 (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_s0) inp_b (va_get_reg64 rRdx va_s0 `op_Division` 8) (va_get_mem_layout va_sM) Public /\ Vale.X64.Decls.modifies_buffer_specific ctx_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) 0 2 /\ va_get_reg64 rR14 va_sM == Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rRbx va_sM == Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rRbp va_sM == Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rR11 va_sM == Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rR12 va_sM == Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_sM) /\ va_get_reg64 rR13 va_sM == va_get_reg64 rR12 va_sM + va_get_reg64 rR12 va_sM `op_Division` 4 /\ va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0 + va_get_reg64 rRdx va_s0 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0 /\ (let r0_in = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_sM) in let r1_in = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_sM) in h == va_mul_nat (va_get_reg64 rRbp va_sM) (va_mul_nat pow2_64 pow2_64) + va_mul_nat (va_get_reg64 rRbx va_sM) pow2_64 + va_get_reg64 rR14 va_sM /\ Vale.Poly1305.Spec_s.modp h == Vale.Poly1305.Util.poly1305_heap_blocks (Vale.Poly1305.Spec_s.modp h_in) (va_mul_nat (va_get_reg64 rRcx va_sM) (va_mul_nat n n)) r (Vale.X64.Decls.buffer64_as_seq (va_get_mem_heaplet 0 va_sM) inp_b) (va_get_reg64 rRdx va_s0 `op_Division` 8))) ==> va_k va_sM ((h)))) val va_wpProof_Poly1305_blocks : r:int -> h_in:int -> ctx_b:buffer64 -> inp_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> int -> Type0) -> Ghost (va_state & va_fuel & int) (requires (va_t_require va_s0 /\ va_wp_Poly1305_blocks r h_in ctx_b inp_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_blocks ()) ([va_Mod_mem_heaplet 1; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_blocks r h_in ctx_b inp_b va_s0 va_k = let (va_sM, va_f0, h) = va_lemma_Poly1305_blocks (va_code_Poly1305_blocks ()) va_s0 r h_in ctx_b inp_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_flags va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))); va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_mem]) va_sM va_s0; let va_g = (h) in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_blocks (r:int) (h_in:int) (ctx_b:buffer64) (inp_b:buffer64) : (va_quickCode int (va_code_Poly1305_blocks ())) = (va_QProc (va_code_Poly1305_blocks ()) ([va_Mod_mem_heaplet 1; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rRax; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_mem]) (va_wp_Poly1305_blocks r h_in ctx_b inp_b) (va_wpProof_Poly1305_blocks r h_in ctx_b inp_b)) //-- //-- Poly1305_last_block val va_code_Poly1305_last_block : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_last_block () = (va_Block (va_CCons (va_IfElse (va_cmp_lt (va_op_cmp_reg64 rR15) (va_const_cmp 8)) (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR15)) (va_CCons (va_code_Shl64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 3)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 1)) (va_CCons (va_code_Shl64 (va_op_dst_opr64_reg64 rRdx) (va_op_shift_amt64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 0)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_CNil ())))))))))))))))) (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR15)) (va_CCons (va_code_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 8)) (va_CCons (va_code_Shl64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 3)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 1)) (va_CCons (va_code_Shl64 (va_op_dst_opr64_reg64 rRdx) (va_op_shift_amt64_reg64 rRcx)) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_const_opr64 0)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_CNil ()))))))))))))))))))) (va_CCons (va_code_Poly1305_iteration ()) (va_CNil ())))) val va_codegen_success_Poly1305_last_block : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_last_block () = (va_pbool_and (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR15)) (va_pbool_and (va_codegen_success_Shl64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 3)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Shl64 (va_op_dst_opr64_reg64 rRdx) (va_op_shift_amt64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR15)) (va_pbool_and (va_codegen_success_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 8)) (va_pbool_and (va_codegen_success_Shl64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 3)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Shl64 (va_op_dst_opr64_reg64 rRdx) (va_op_shift_amt64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdx)) (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0))))))))))))))))))))))))))))) (va_pbool_and (va_codegen_success_Poly1305_iteration ()) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_last_block (va_mods:va_mods_t) : (va_quickCode unit (va_code_Poly1305_last_block ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r1:nat64) = va_get_reg64 rRax va_s in let (r:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s) r1 in let (hBlocks:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s)) (va_get_reg64 rRbp va_s) in let (inpLast:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s) (va_get_reg64 rR9 va_s) in let (padLast:Prims.pos) = Prims.pow2 (va_get_reg64 rR15 va_s `op_Multiply` 8) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 409 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_qIf va_mods (Cmp_lt (va_op_cmp_reg64 rR15) (va_const_cmp 8)) (qblock va_mods (fun (va_s:va_state) -> let (va_arg78:Vale.Def.Types_s.nat64) = va_get_reg64 rR15 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 410 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_bytes_shift_power2 va_arg78) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 411 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR15)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 412 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shl64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 413 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 414 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shl64 (va_op_dst_opr64_reg64 rRdx) (va_op_shift_amt64_reg64 rRcx)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 415 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRdx va_s == padLast) (let (va_arg77:Vale.Def.Types_s.nat64) = va_get_reg64 rR15 va_s in let (va_arg76:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 417 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_bytes_and_mod va_arg76 va_arg77) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 419 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (padLast == Vale.Poly1305.Math.shift_left64 1 (Vale.Poly1305.Math.shift_left64 (va_get_reg64 rR15 va_s) 3)) (let (va_arg75:Prims.int) = Prims.pow2 (va_get_reg64 rR15 va_s `op_Multiply` 8) in let (va_arg74:Prims.int) = va_get_reg64 rR15 va_s in let (va_arg73:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in let (va_arg72:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 420 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mod_power2_lo va_arg72 va_arg73 va_arg74 va_arg75) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 421 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 422 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 423 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 424 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 425 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR8 va_s == va_get_reg64 rR8 va_old_s `op_Modulus` padLast) (va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 426 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s) (va_get_reg64 rR9 va_s) == inpLast `op_Modulus` padLast) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 429 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 430 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 431 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 433 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 434 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 435 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_QEmpty (())))))))))))))))))))))))) (qblock va_mods (fun (va_s:va_state) -> va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 437 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rR15 va_s - 8 >= 0 /\ va_get_reg64 rR15 va_s - 8 <= 255) (fun _ -> let (nExtra8:nat8) = va_get_reg64 rR15 va_s - 8 in let (va_arg85:Vale.Def.Types_s.nat64) = nExtra8 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 438 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_bytes_shift_power2 va_arg85) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 439 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR15)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 440 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 441 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shl64 (va_op_dst_opr64_reg64 rRcx) (va_const_shift_amt64 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 442 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 443 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shl64 (va_op_dst_opr64_reg64 rRdx) (va_op_shift_amt64_reg64 rRcx)) (fun (va_s:va_state) _ -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (padLast == Vale.Poly1305.Math.lowerUpper128 0 (va_get_reg64 rRdx va_s)) (let (va_arg84:Prims.nat) = 8 `op_Multiply` nExtra8 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 446 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_power2_add64 va_arg84) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 447 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (())))) (let (va_arg83:Vale.Def.Types_s.nat64) = nExtra8 in let (va_arg82:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 451 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_bytes_and_mod va_arg82 va_arg83) (va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 452 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Prims.pow2 (8 `op_Multiply` nExtra8) >= 0 /\ Prims.pow2 (8 `op_Multiply` nExtra8) <= 18446744073709551615) (fun _ -> let (va_arg81:Vale.Def.Types_s.nat64) = Prims.pow2 (8 `op_Multiply` nExtra8) in let (va_arg80:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in let (va_arg79:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 452 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_mod_hi va_arg79 va_arg80 va_arg81) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 453 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 454 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 455 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRcx)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 456 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s) (va_get_reg64 rR9 va_s) == inpLast `op_Modulus` padLast) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 459 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 460 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 461 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 463 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 464 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 465 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbp) (va_const_opr64 0)) (va_QEmpty (()))))))))))))))))))))))))) (fun (va_s:va_state) va_g -> let (h:int) = hBlocks + inpLast `op_Modulus` padLast + padLast in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 469 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == va_mul_nat (va_get_reg64 rRbp va_s) (va_mul_nat n n) + va_mul_nat (va_get_reg64 rRbx va_s) n + va_get_reg64 rR14 va_s) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 469 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper192_reveal ()) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 469 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (())))) (va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 470 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (r == va_mul_nat r1 n + va_get_reg64 rR11 va_s) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 470 column 54 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (()))) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 471 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_iteration r1) (fun (va_s:va_state) (hLast:int) -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 472 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (hLast == Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s)) (va_get_reg64 rRbp va_s)) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 472 column 87 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper192_reveal ()) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 472 column 111 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (())))) (let (va_arg71:Prims.int) = r in let (va_arg70:Prims.int) = inpLast `op_Modulus` padLast + padLast in let (va_arg69:Prims.pos) = p in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 473 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_demod va_arg69 hBlocks va_arg70 va_arg71) (va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 474 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp hLast == Vale.Poly1305.Spec_s.modp ((Vale.Poly1305.Spec_s.modp hBlocks + padLast + inpLast `op_Modulus` padLast) `op_Multiply` r)) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 474 column 90 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true (fun _ -> va_reveal_eq (`%modp) modp modp) (fun _ -> va_reveal_opaque (`%modp) modp) (va_QEmpty (()))) (va_QEmpty (())))))))))) val va_lemma_Poly1305_last_block : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Poly1305_last_block ()) va_s0 /\ va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r1:nat64) = va_get_reg64 rRax va_s0 in let (r:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s0) r1 in let (hBlocks:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in let (inpLast:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s0) (va_get_reg64 rR9 va_s0) in va_get_reg64 rRbp va_s0 < 5 /\ va_get_reg64 rR11 va_s0 < n `op_Division` 16 /\ r1 < n `op_Division` 16 /\ r1 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == r1 + r1 `op_Division` 4 /\ (1 <= va_get_reg64 rR15 va_s0 /\ va_get_reg64 rR15 va_s0 < 16)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r1:nat64) = va_get_reg64 rRax va_s0 in let (r:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s0) r1 in let (hBlocks:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in let (inpLast:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s0) (va_get_reg64 rR9 va_s0) in va_get_reg64 rRbp va_sM < 5 /\ (let padLast = Prims.pow2 (va_get_reg64 rR15 va_sM `op_Multiply` 8) in let hLast = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM)) (va_get_reg64 rRbp va_sM) in Vale.Poly1305.Spec_s.modp hLast == Vale.Poly1305.Spec_s.modp ((Vale.Poly1305.Spec_s.modp hBlocks + padLast + inpLast `op_Modulus` padLast) `op_Multiply` r))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0))))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_last_block va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok] in let va_qc = va_qcode_Poly1305_last_block va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_last_block ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 380 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r1:nat64) = va_get_reg64 rRax va_s0 in let (r:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s0) r1 in let (hBlocks:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in let (inpLast:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s0) (va_get_reg64 rR9 va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 402 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_reg64 rRbp va_sM < 5) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 403 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (let padLast = Prims.pow2 (va_get_reg64 rR15 va_sM `op_Multiply` 8) in label va_range1 "***** POSTCONDITION NOT MET AT line 404 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (let hLast = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM)) (va_get_reg64 rRbp va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 405 column 81 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Spec_s.modp hLast == Vale.Poly1305.Spec_s.modp ((Vale.Poly1305.Spec_s.modp hBlocks + padLast + inpLast `op_Modulus` padLast) `op_Multiply` r)))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Poly1305_last_block (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r1:nat64) = va_get_reg64 rRax va_s0 in let (r:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s0) r1 in let (hBlocks:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in let (inpLast:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s0) (va_get_reg64 rR9 va_s0) in va_get_reg64 rRbp va_s0 < 5 /\ va_get_reg64 rR11 va_s0 < n `op_Division` 16 /\ r1 < n `op_Division` 16 /\ r1 `op_Modulus` 4 == 0 /\ va_get_reg64 rR13 va_s0 == r1 + r1 `op_Division` 4 /\ (1 <= va_get_reg64 rR15 va_s0 /\ va_get_reg64 rR15 va_s0 < 16)) /\ (forall (va_x_rax:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_rbp:nat64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRax va_x_rax va_s0))))))))) in va_get_ok va_sM /\ (let (n:(va_int_range 18446744073709551616 18446744073709551616)) = 18446744073709551616 in let (p:(va_int_range 1361129467683753853853498429727072845819 1361129467683753853853498429727072845819)) = va_mul_nat n n `op_Multiply` 4 - 5 in let (r1:nat64) = va_get_reg64 rRax va_s0 in let (r:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s0) r1 in let (hBlocks:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in let (inpLast:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s0) (va_get_reg64 rR9 va_s0) in va_get_reg64 rRbp va_sM < 5 /\ (let padLast = Prims.pow2 (va_get_reg64 rR15 va_sM `op_Multiply` 8) in let hLast = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM)) (va_get_reg64 rRbp va_sM) in Vale.Poly1305.Spec_s.modp hLast == Vale.Poly1305.Spec_s.modp ((Vale.Poly1305.Spec_s.modp hBlocks + padLast + inpLast `op_Modulus` padLast) `op_Multiply` r))) ==> va_k va_sM (()))) val va_wpProof_Poly1305_last_block : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Poly1305_last_block va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_last_block ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_last_block va_s0 va_k = let (va_sM, va_f0) = va_lemma_Poly1305_last_block (va_code_Poly1305_last_block ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM va_s0)))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_last_block () : (va_quickCode unit (va_code_Poly1305_last_block ())) = (va_QProc (va_code_Poly1305_last_block ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRax]) va_wp_Poly1305_last_block va_wpProof_Poly1305_last_block) //-- //-- Poly1305_reduce_last val va_code_Poly1305_reduce_last : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_reduce_last () = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR14)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbp)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR8) (va_const_opr64 5)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_CCons (va_code_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 2)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 0)) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_CNil ()))))))))))))))))))) val va_codegen_success_Poly1305_reduce_last : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_reduce_last () = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR14)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbp)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR8) (va_const_opr64 5)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 2)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Add64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Add64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_ttrue ())))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_reduce_last (va_mods:va_mods_t) : (va_quickCode unit (va_code_Poly1305_reduce_last ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (h:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s)) (va_get_reg64 rRbp va_s) in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 490 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 492 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR14)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 493 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 494 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rRbp)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 495 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR8) (va_const_opr64 5)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 496 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 497 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (fun (va_s:va_state) _ -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 499 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h + 5 == Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR8 va_s) (va_get_reg64 rR9 va_s)) (va_get_reg64 rR10 va_s)) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 500 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 500 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lowerUpper192_reveal ()) (va_QEmpty (())))) (let (va_arg32:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in let (va_arg31:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in let (va_arg30:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg29:Prims.int) = h + 5 in let (va_arg28:Vale.Def.Types_s.nat64) = va_get_reg64 rR14 va_old_s in let (va_arg27:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_old_s in let (va_arg26:Vale.Def.Types_s.nat64) = va_get_reg64 rRbp va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 501 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_reduce128 h va_arg26 va_arg27 va_arg28 va_arg29 va_arg30 va_arg31 va_arg32) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Shr64 (va_op_dst_opr64_reg64 rR10) (va_const_shift_amt64 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 505 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 506 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rRax) (va_const_opr64 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 508 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 509 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 511 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 512 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 514 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 515 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 518 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 519 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR9)) (va_QEmpty (()))))))))))))))))))))))) val va_lemma_Poly1305_reduce_last : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Poly1305_reduce_last ()) va_s0 /\ va_get_ok va_s0 /\ (let (h:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in va_get_reg64 rRbp va_s0 < 5))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (h:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM) == Vale.Poly1305.Spec_s.mod2_128 (Vale.Poly1305.Spec_s.modp h)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_Poly1305_reduce_last va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rRax; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok] in let va_qc = va_qcode_Poly1305_reduce_last va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_reduce_last ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 478 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (h:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 488 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM) == Vale.Poly1305.Spec_s.mod2_128 (Vale.Poly1305.Spec_s.modp h)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rRax; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Poly1305_reduce_last (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (h:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in va_get_reg64 rRbp va_s0 < 5) /\ (forall (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_rax:nat64) (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_rbp:nat64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rRax va_x_rax (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 va_s0))))))) in va_get_ok va_sM /\ (let (h:Prims.int) = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0)) (va_get_reg64 rRbp va_s0) in Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM) == Vale.Poly1305.Spec_s.mod2_128 (Vale.Poly1305.Spec_s.modp h)) ==> va_k va_sM (()))) val va_wpProof_Poly1305_reduce_last : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Poly1305_reduce_last va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_reduce_last ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rRax; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_reduce_last va_s0 va_k = let (va_sM, va_f0) = va_lemma_Poly1305_reduce_last (va_code_Poly1305_reduce_last ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rRax va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rRax; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_reduce_last () : (va_quickCode unit (va_code_Poly1305_reduce_last ())) = (va_QProc (va_code_Poly1305_reduce_last ()) ([va_Mod_flags; va_Mod_reg64 rRbp; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_reg64 rRax; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8]) va_wp_Poly1305_reduce_last va_wpProof_Poly1305_reduce_last) //-- //-- Poly1305_add_key_s val va_code_Poly1305_add_key_s : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_add_key_s () = (va_Block (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) val va_codegen_success_Poly1305_add_key_s : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_add_key_s () = (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdx)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_Poly1305_add_key_s (va_mods:va_mods_t) : (va_quickCode unit (va_code_Poly1305_add_key_s ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (h_in:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s) (va_get_reg64 rRbx va_s) in let (key_s:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rRax va_s) (va_get_reg64 rRdx va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 536 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRax)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 537 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdx)) (fun (va_s:va_state) _ -> let (va_arg18:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg17:Vale.Def.Types_s.nat64) = va_get_reg64 rR14 va_s in let (va_arg16:Prims.int) = key_s in let (va_arg15:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg14:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in let (va_arg13:Prims.int) = h_in in let (va_arg12:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_old_s in let (va_arg11:Vale.Def.Types_s.nat64) = va_get_reg64 rR14 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 539 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_:unit) -> Vale.Poly1305.Math.lemma_add_key va_arg11 va_arg12 va_arg13 va_arg14 va_arg15 va_arg16 va_arg17 va_arg18) (va_QEmpty (())))))) val va_lemma_Poly1305_add_key_s : va_b0:va_code -> va_s0:va_state -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Poly1305_add_key_s ()) va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (h_in:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0) in let (key_s:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rRax va_s0) (va_get_reg64 rRdx va_s0) in Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM) == Vale.Poly1305.Spec_s.mod2_128 (h_in + key_s)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_Poly1305_add_key_s va_b0 va_s0 = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_ok] in let va_qc = va_qcode_Poly1305_add_key_s va_mods in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Poly1305_add_key_s ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 523 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_get_ok va_sM) /\ (let (h_in:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0) in let (key_s:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rRax va_s0) (va_get_reg64 rRdx va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 534 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM) == Vale.Poly1305.Spec_s.mod2_128 (h_in + key_s)))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbx; va_Mod_reg64 rR14; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Poly1305_add_key_s (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (forall (va_x_r14:nat64) (va_x_rbx:nat64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR14 va_x_r14 va_s0)) in va_get_ok va_sM /\ (let (h_in:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_s0) (va_get_reg64 rRbx va_s0) in let (key_s:Vale.Def.Words_s.nat128) = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rRax va_s0) (va_get_reg64 rRdx va_s0) in Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR14 va_sM) (va_get_reg64 rRbx va_sM) == Vale.Poly1305.Spec_s.mod2_128 (h_in + key_s)) ==> va_k va_sM (()))) val va_wpProof_Poly1305_add_key_s : va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Poly1305_add_key_s va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Poly1305_add_key_s ()) ([va_Mod_flags; va_Mod_reg64 rRbx; va_Mod_reg64 rR14]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Poly1305_add_key_s va_s0 va_k = let (va_sM, va_f0) = va_lemma_Poly1305_add_key_s (va_code_Poly1305_add_key_s ()) va_s0 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR14 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_reg64 rRbx; va_Mod_reg64 rR14]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Poly1305_add_key_s () : (va_quickCode unit (va_code_Poly1305_add_key_s ())) = (va_QProc (va_code_Poly1305_add_key_s ()) ([va_Mod_flags; va_Mod_reg64 rRbx; va_Mod_reg64 rR14]) va_wp_Poly1305_add_key_s va_wpProof_Poly1305_add_key_s) //-- // REVIEW: not clear why Vale.Def.TypesNative_s.reveal_iand doesn't work directly let reveal_logand128 (x y:nat128) : Lemma (requires True) (ensures Vale.Def.Types_s.iand x y == FStar.UInt.logand #128 x y) = Vale.Def.TypesNative_s.reveal_iand 128 x y //-- reveal_logand128 //-- //-- Poly1305_impl val va_code_Poly1305_impl : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Poly1305_impl () = (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR12) (va_op_reg_opr64_reg64 rRdi) 32 Public) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413247)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413244)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Public) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR12) 32 Public) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 15)) (va_CCons (va_code_Sub64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRax) 56 Public) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 64 Public) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_CCons (va_code_Poly1305_blocks ()) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 184 Public) (va_CCons (va_IfElse (va_cmp_eq (va_op_cmp_reg64 rRax) (va_const_cmp 1)) (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRdi) 56 Public) (va_CCons (va_IfElse (va_cmp_ne (va_op_cmp_reg64 rR15) (va_const_cmp 0)) (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 32 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Public) (va_CCons (va_code_Poly1305_last_block ()) (va_CNil ())))))) (va_Block (va_CNil ()))) (va_CCons (va_code_Poly1305_reduce_last ()) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 40 Public) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRdi) 48 Public) (va_CCons (va_code_Poly1305_add_key_s ()) (va_CNil ())))))))) (va_Block (va_CNil ()))) (va_CNil ()))))))))))))))))))) val va_codegen_success_Poly1305_impl : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Poly1305_impl () = (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR12) (va_op_reg_opr64_reg64 rRdi) 32 Public) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413247)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413244)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Public) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR12) 32 Public) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rRax) (va_const_opr64 15)) (va_pbool_and (va_codegen_success_Sub64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRax) 56 Public) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 64 Public) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (va_pbool_and (va_codegen_success_Poly1305_blocks ()) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 184 Public) (va_pbool_and (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRdi) 56 Public) (va_pbool_and (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 32 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Public) (va_codegen_success_Poly1305_last_block ())))) (va_pbool_and (va_codegen_success_Poly1305_reduce_last ()) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRdi) 40 Public) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRdi) 48 Public) (va_codegen_success_Poly1305_add_key_s ())))))) (va_ttrue ()))))))))))))))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.Poly1305.Util.fsti.checked", "Vale.Poly1305.Spec_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Poly1305.X64.fst" }
[ { "abbrev": false, "full_module": "Vale.Poly1305.Util", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Util", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_mods: Vale.X64.QuickCode.va_mods_t -> key_r: Vale.X64.Machine_s.nat128 -> key_s: Vale.X64.Machine_s.nat128 -> ctx_b: Vale.X64.Memory.buffer64 -> inp_b: Vale.X64.Memory.buffer64 -> finish: Vale.X64.Memory.nat64 -> Vale.X64.QuickCode.va_quickCode Prims.int (Vale.Poly1305.X64.va_code_Poly1305_impl ())
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.Machine_s.nat128", "Vale.X64.Memory.buffer64", "Vale.X64.Memory.nat64", "Vale.X64.QuickCodes.qblock", "Prims.int", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsMem.va_code_Load64_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR11", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Machine_s.rR12", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Machine_s.rRcx", "Vale.X64.Decls.va_const_opr64", "Vale.X64.InsBasic.va_code_And64", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.InsMem.va_code_Store64_buffer", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRdx", "Vale.X64.InsBasic.va_code_Sub64", "Vale.Poly1305.X64.va_code_Poly1305_blocks", "Vale.X64.Machine_s.IfElse", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.QuickCodes.cmp_to_ocmp", "Vale.X64.QuickCodes.Cmp_eq", "Vale.X64.Decls.va_op_cmp_reg64", "Vale.X64.Decls.va_const_cmp", "Vale.X64.QuickCodes.block", "Vale.X64.Machine_s.rR15", "Vale.X64.QuickCodes.Cmp_ne", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rR9", "Vale.Poly1305.X64.va_code_Poly1305_last_block", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.Poly1305.X64.va_code_Poly1305_reduce_last", "Vale.Poly1305.X64.va_code_Poly1305_add_key_s", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.unit", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Vale.Def.Words_s.nat64", "Prims.eq2", "Vale.Def.Types_s.ishr", "Prims.op_Division", "Vale.Def.Types_s.iand", "Prims.op_Modulus", "Prims.op_Multiply", "Prims.b2t", "Prims.op_LessThan", "Vale.X64.QuickCodes.va_range1", "Vale.Poly1305.Math.lemma_poly_bits64", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.InsMem.va_quick_Load64_buffer", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.InsBasic.va_quick_And64", "Vale.X64.InsMem.va_quick_Store64_buffer", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_qAssertBy", "Prims.op_Addition", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Decls.va_mul_nat", "Vale.Def.Words_s.nat128", "Vale.Poly1305.Math.lowerUpper128", "Vale.Poly1305.Math.lowerUpper128_def", "Vale.Poly1305.Math.lowerUpper128_reveal", "Vale.X64.QuickCodes.va_QEmpty", "Vale.Arch.Types.iand128", "Vale.Poly1305.Math.lemma_lowerUpper128_and", "Vale.X64.InsBasic.va_quick_Sub64", "Vale.Poly1305.Math.lowerUpper192", "Vale.Poly1305.Math.lowerUpper192_def", "Vale.Poly1305.Math.lowerUpper192_reveal", "Vale.Poly1305.X64.va_quick_Poly1305_blocks", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRbp", "Prims.op_LessThanOrEqual", "Vale.X64.Memory.buffer_length", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.Seq.Base.length", "Vale.X64.Memory.buffer_as_seq", "Vale.Poly1305.Util.poly1305_heap_blocks", "Vale.Poly1305.Spec_s.poly1305_hash_blocks", "Vale.Poly1305.Util.seqTo128", "Vale.Poly1305.Util.lemma_poly1305_heap_hash_blocks_alt", "Vale.X64.QuickCodes.va_qIf", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt.logand", "Vale.Poly1305.X64.reveal_logand128", "Vale.X64.QuickCodes.va_qAssert", "Vale.Poly1305.Math.bare_r", "Vale.Poly1305.X64.va_quick_Poly1305_last_block", "Vale.X64.QuickCodes.quickCodes", "Vale.Poly1305.Util.seqTo128_app", "Vale.X64.Decls.buffer64_as_seq", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.Poly1305.Spec_s.mod2_128", "Vale.Poly1305.Math.lemma_add_mod128", "Vale.Poly1305.X64.va_quick_Poly1305_reduce_last", "Vale.Poly1305.X64.va_quick_Poly1305_add_key_s", "Vale.Poly1305.Spec_s.poly1305_hash_all", "Vale.Poly1305.Spec_s.modp", "Vale.X64.QuickCodes.va_QLemma", "Prims.squash", "Vale.X64.Decls.va_reveal_eq", "Vale.X64.Decls.va_reveal_opaque", "Vale.Arch.HeapImpl.vale_heap", "Vale.X64.Decls.buffer64_read", "Vale.X64.Decls.va_int_range", "Vale.X64.Machine_s.pow2_64", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.Poly1305.X64.va_code_Poly1305_impl" ]
[]
false
false
false
false
false
let va_qcode_Poly1305_impl (va_mods: va_mods_t) (key_r key_s: nat128) (ctx_b inp_b: buffer64) (finish: nat64) : (va_quickCode (int) (va_code_Poly1305_impl ())) =
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in let n:(va_int_range 18446744073709551616 18446744073709551616) = pow2_64 in let inp_in:nat64 = va_get_reg64 rRsi va_s in let len_in:nat64 = va_get_reg64 rRdx va_s in let h0_in:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read ctx_b 0 (va_get_mem_heaplet 1 va_s) in let h1_in:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read ctx_b 1 (va_get_mem_heaplet 1 va_s) in let h2_in:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read ctx_b 2 (va_get_mem_heaplet 1 va_s) in let h_in:Prims.int = Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 h0_in h1_in) h2_in in let key_r0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read ctx_b 3 (va_get_mem_heaplet 1 va_s) in let key_r1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read ctx_b 4 (va_get_mem_heaplet 1 va_s) in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 607 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_: unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 609 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRdi) 24 Public ctx_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 610 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_dst_opr64_reg64 rR12) (va_op_reg_opr64_reg64 rRdi) 32 Public ctx_b 4) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 611 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413247)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 612 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 613 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1152921487695413244)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 614 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 615 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Public ctx_b 3) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 616 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR12) 32 Public ctx_b 4) (fun (va_s: va_state) _ -> let r:nat128 = Vale.Poly1305.Math.lowerUpper128 (va_get_reg64 rR11 va_s) (va_get_reg64 rR12 va_s) in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 619 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (r == va_get_reg64 rR11 va_s + va_mul_nat n (va_get_reg64 rR12 va_s)) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 619 column 54 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_: unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_QEmpty (()))) (let mask:nat128 = 21267647620597763993911028882763415551 in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 622 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (r == Vale.Arch.Types.iand128 key_r mask) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 624 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_: unit) -> Vale.Poly1305.Math.lowerUpper128_reveal () ) (let va_arg81:Vale.Def.Types_s.nat64 = va_get_reg64 rR12 va_s in let va_arg80:Vale.Def.Types_s.nat64 = va_get_reg64 rR11 va_s in let va_arg79:Vale.Def.Words_s.nat128 = r in let va_arg78:Vale.Def.Words_s.nat128 = mask in let va_arg77:Vale.Def.Words_s.nat128 = key_r in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 625 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_: unit) -> Vale.Poly1305.Math.lemma_lowerUpper128_and va_arg77 key_r0 key_r1 va_arg78 1152921487695413247 1152921487695413244 va_arg79 va_arg80 va_arg81) (va_QEmpty (())))) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 629 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 630 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_And64 (va_op_dst_opr64_reg64 rRax ) (va_const_opr64 15)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 631 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Sub64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 634 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRax) 56 Public ctx_b 7) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 635 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi ) (va_op_reg_opr64_reg64 rRdx ) 64 Public ctx_b 8) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 637 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_const_opr64 1)) (fun (va_s: va_state) _ -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 638 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h_in == va_mul_nat h2_in (va_mul_nat n n) + va_mul_nat h1_in n + h0_in) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 638 column 81 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_: unit) -> Vale.Poly1305.Math.lowerUpper128_reveal ()) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 638 column 105 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun (_: unit ) -> Vale.Poly1305.Math.lowerUpper192_reveal ()) (va_QEmpty (()))) ) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 639 column 7 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (va_quick_Poly1305_blocks r h_in ctx_b inp_b) (fun (va_s: va_state ) (h: int) -> va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 640 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (h == Vale.Poly1305.Math.lowerUpper192 (Vale.Poly1305.Math.lowerUpper128 ( va_get_reg64 rR14 va_s ) ( va_get_reg64 rRbx va_s ) ) (va_get_reg64 rRbp va_s )) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 641 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun ( _: unit ) -> Vale.Poly1305.Math.lowerUpper192_reveal () ) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 641 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( fun ( _: unit ) -> Vale.Poly1305.Math.lowerUpper128_reveal () ) ( va_QEmpty ( () ) ) )) (let va_arg76:Prims.int = (va_get_reg64 rRdx va_old_s ) `op_Division` 16 in let va_arg75:Vale.X64.Memory.buffer64 = inp_b in let va_arg74:Vale.X64.Memory.vale_heap = va_get_mem_heaplet 0 va_s in let va_arg73:Prims.int = r in let va_arg72:Prims.int = va_mul_nat n n in let va_arg71:Prims.int = Vale.Poly1305.Spec_s.modp h_in in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 642 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" (fun ( _: unit ) -> Vale.Poly1305.Util.lemma_poly1305_heap_hash_blocks_alt va_arg71 va_arg72 va_arg73 va_arg74 va_arg75 va_arg76 ) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 644 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 1 ) ( va_op_dst_opr64_reg64 rRax ) ( va_op_reg_opr64_reg64 rRdi ) 184 Public ctx_b 23 ) ( fun ( va_s: va_state ) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 645 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_qIf va_mods ( Cmp_eq ( va_op_cmp_reg64 rRax ) ( va_const_cmp 1 ) ) ( qblock va_mods ( fun ( va_s: va_state ) -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 647 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( fun ( _: unit ) -> reveal_logand128 key_r mask ) ( va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 648 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( r == Vale.Poly1305.Math.bare_r key_r ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 650 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 1 ) ( va_op_dst_opr64_reg64 rR15 ) ( va_op_reg_opr64_reg64 rRdi ) 56 Public ctx_b 7 ) ( fun ( va_s: va_state ) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 652 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_qIf va_mods ( Cmp_ne ( va_op_cmp_reg64 rR15 ) ( va_const_cmp 0 ) ) ( qblock va_mods ( fun ( va_s: va_state ) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 654 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 1 ) ( va_op_dst_opr64_reg64 rRax ) ( va_op_reg_opr64_reg64 rRdi ) 32 Public ctx_b 4 ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 655 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 0 ) ( va_op_dst_opr64_reg64 rR8 ) ( va_op_reg_opr64_reg64 rRsi ) 0 Public inp_b ( ( len_in `op_Division` 16 ) `op_Multiply` 2 ) ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 656 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 0 ) ( va_op_dst_opr64_reg64 rR9 ) ( va_op_reg_opr64_reg64 rRsi ) 8 Public inp_b ( ( len_in `op_Division` 16 ) `op_Multiply` 2 + 1 ) ) ( fun ( va_s: va_state ) _ -> let a:Vale.X64.Machine_s.nat128 = Vale.Poly1305.Util.seqTo128_app ( Vale.X64.Decls.buffer64_as_seq ( va_get_mem_heaplet 0 va_s ) inp_b ) ( len_in `op_Division` 16 ) in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 658 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( Vale.Poly1305.Math.lowerUpper128 ( va_get_reg64 rR8 va_s ) ( va_get_reg64 rR9 va_s ) == a ) ( va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 659 column 42 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( fun ( _: unit ) -> Vale.Poly1305.Math.lowerUpper128_reveal () ) ( va_QEmpty ( () ) ) ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 660 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Poly1305_last_block () ) ( fun ( va_s: va_state ) _ -> let h:int = Vale.Poly1305.Math.lowerUpper192 ( Vale.Poly1305.Math.lowerUpper128 ( va_get_reg64 rR14 va_s ) ( va_get_reg64 rRbx va_s ) ) ( va_get_reg64 rRbp va_s ) in va_QEmpty ( ( h ) ) ) ) ) ) ) ) ) ( qblock va_mods ( fun ( va_s: va_state ) -> va_QEmpty ( ( h ) ) ) ) ) ( fun ( va_s: va_state ) va_g -> let h:int = va_g in let va_arg70:Prims.int = key_s in let va_arg69:Prims.int = Vale.Poly1305.Spec_s.modp h in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 664 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( fun ( _: unit ) -> Vale.Poly1305.Math.lemma_add_mod128 va_arg69 va_arg70 ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 665 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Poly1305_reduce_last () ) ( fun ( va_s: va_state ) _ -> let h:int = Vale.Poly1305.Math.lowerUpper128 ( va_get_reg64 rR14 va_s ) ( va_get_reg64 rRbx va_s ) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 668 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 1 ) ( va_op_dst_opr64_reg64 rRax ) ( va_op_reg_opr64_reg64 rRdi ) 40 Public ctx_b 5 ) ( va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 669 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Load64_buffer ( va_op_heaplet_mem_heaplet 1 ) ( va_op_dst_opr64_reg64 rRdx ) ( va_op_reg_opr64_reg64 rRdi ) 48 Public ctx_b 6 ) ( va_QBind va_range1 "***** PRECONDITION NOT MET AT line 670 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( va_quick_Poly1305_add_key_s () ) ( fun ( va_s: va_state ) _ -> let h:int = Vale.Poly1305.Math.lowerUpper128 ( va_get_reg64 rR14 va_s ) ( va_get_reg64 rRbx va_s ) in va_qAssertBy va_range1 "***** PRECONDITION NOT MET AT line 673 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" ( h == Vale.Poly1305.Spec_s.poly1305_hash_all ( Vale.Poly1305.Spec_s.modp h_in ) key_r key_s ( Vale.Poly1305.Util.seqTo128 ( Vale.X64.Decls.buffer64_as_seq ( va_get_mem_heaplet 0 va_s ) inp_b ) ) len_in ) ( va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 674 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true ( fun _ -> va_reveal_eq ( `%mod2_128 ) mod2_128 mod2_128 ) ( fun _ -> va_reveal_opaque ( `%mod2_128 ) mod2_128 ) ( va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 674 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/OpenSSL/poly1305/x64/Vale.Poly1305.X64.vaf *****" true ( fun _ -> va_reveal_eq ( `%modp ) modp modp ) ( fun _ -> va_reveal_opaque ( `%modp ) modp ) ( va_QEmpty ( () ) ) ) ) ( va_QEmpty ( ( h ) ) ) ) ) ) ) ) ) ) ) ) ) ) ( qblock va_mods ( fun ( va_s: va_state ) -> va_QEmpty ( ( h ) ) ) ) ) ( fun ( va_s: va_state ) va_g -> let h:int = va_g in va_QEmpty ( ( h ) ) ) ) )) )))))))))))))) )))))))
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.ex
val ex : a: Type -> Type
let ex (a:Type) = unit -> M (either a exn)
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 29, "start_col": 0, "start_line": 29 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.either", "Prims.exn" ]
[]
false
false
false
true
true
let ex (a: Type) =
unit -> M (either a exn)
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.return_ex
val return_ex : (a:Type) -> (x:a) -> ex a
val return_ex : (a:Type) -> (x:a) -> ex a
let return_ex a x = fun _ -> Inl x
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 33, "start_col": 0, "start_line": 33 }
(* 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.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> FStar.DM4F.Exceptions.ex a
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.Inl", "Prims.exn", "FStar.Pervasives.either" ]
[]
false
false
false
true
false
let return_ex a x =
fun _ -> Inl x
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.raise0
val raise0 (a: Type) (e: exn) : ex a
val raise0 (a: Type) (e: exn) : ex a
let raise0 (a:Type) (e:exn) : ex a = fun _ -> Inr e
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 42, "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 FStar.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> ex a let return_ex a x = fun _ -> Inl x val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b let bind_ex a b f g = fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> e: Prims.exn -> FStar.DM4F.Exceptions.ex a
Prims.Tot
[ "total" ]
[]
[ "Prims.exn", "Prims.unit", "FStar.Pervasives.Inr", "FStar.Pervasives.either", "FStar.DM4F.Exceptions.ex" ]
[]
false
false
false
true
false
let raise0 (a: Type) (e: exn) : ex a =
fun _ -> Inr e
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.bind_ex
val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b
val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b
let bind_ex a b f g = fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x ()
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 40, "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 FStar.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> ex a let return_ex a x = fun _ -> Inl x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: Type -> f: FStar.DM4F.Exceptions.ex a -> g: (g: a -> FStar.DM4F.Exceptions.ex b) -> FStar.DM4F.Exceptions.ex b
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Exceptions.ex", "Prims.unit", "Prims.exn", "FStar.Pervasives.Inr", "FStar.Pervasives.either" ]
[]
false
false
false
true
false
let bind_ex a b f g =
fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x ()
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.div_intrinsic
val div_intrinsic : i:nat -> j:int -> Exn int (requires True) (ensures (function | Inr Division_by_zero -> j=0 | Inl z -> j<>0 /\ z = i / j | _ -> True))
val div_intrinsic : i:nat -> j:int -> Exn int (requires True) (ensures (function | Inr Division_by_zero -> j=0 | Inl z -> j<>0 /\ z = i / j | _ -> True))
let div_intrinsic i j = if j=0 then raise Division_by_zero else i / j
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 100, "start_col": 0, "start_line": 98 }
(* 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.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> ex a let return_ex a x = fun _ -> Inl x val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b let bind_ex a b f g = fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x () let raise0 (a:Type) (e:exn) : ex a = fun _ -> Inr e (* Define the new effect using DM4F *) total reifiable reflectable new_effect { EXN : (a:Type) -> Effect with repr = ex ; bind = bind_ex ; return = return_ex ; raise (#a:Type) = raise0 a } let raise = EXN?.raise (* An effect to alias easily write pre- and postconditions *) (* Note: we use Type0 instead of EXN?.pre to avoid having to thunk everything. *) effect Exn (a:Type) (pre:Type0) (post:EXN?.post a) = EXN a (fun (_:unit) (p:EXN?.post a) -> pre /\ (forall (r:either a exn). (pre /\ post r) ==> p r)) (* Another alias. Ex a is the effect type for total exception-throwing * programs. i.e. Any program of type `Ex a´ will throw or finish * correctly, but never loop. *) effect Ex (a:Type) = EXN a (fun _ p -> forall x. p x) (* * We now show `div´ to be correct in two ways. The property we show is * that if `div´ throws, then the divisor was zero; and if it doesn't, * then the divisor was not zero and the result (z) is the division of i * and j. * * In the first definition, we give a strong type to `div´: we make use * of `Exn´ to give pre- and postconditions to the function, specifying * the property we want. This is known as an intrinsic proof: it's * within the definition. * * In the second, we give a very lax type to div, namely `Ex int´ (note * it is different from Exn). This type is only implying that calling * div will either throw an exception or return an int, but there's no * specification about the result or about when exceptions occur. * * As `Ex´ is a effect, we can reason about `div´ outside of * its definition by turning it into a pure function. This is what is * done in the `lemma_div_extrinsic´ lemma. * * For primitive effects, this is impossible since logical properties * (in proof-irrelevant contexts) only make sense for pure and total * terms, so one is only able to do proofs intrinsically. *) exception Division_by_zero val div_intrinsic : i:nat -> j:int -> Exn int (requires True) (ensures (function | Inr Division_by_zero -> j=0 | Inl z -> j<>0 /\ z = i / j
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat -> j: Prims.int -> FStar.DM4F.Exceptions.Exn Prims.int
FStar.DM4F.Exceptions.Exn
[]
[]
[ "Prims.nat", "Prims.int", "Prims.op_Equality", "FStar.DM4F.Exceptions.raise", "FStar.DM4F.Exceptions.Division_by_zero", "Prims.bool", "Prims.op_Division" ]
[]
false
true
false
false
false
let div_intrinsic i j =
if j = 0 then raise Division_by_zero else i / j
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.div_extrinsic
val div_extrinsic (i: nat) (j: int) : Ex int
val div_extrinsic (i: nat) (j: int) : Ex int
let div_extrinsic (i:nat) (j:int) : Ex int = if j=0 then raise Division_by_zero else i / j
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 104, "start_col": 1, "start_line": 102 }
(* 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.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> ex a let return_ex a x = fun _ -> Inl x val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b let bind_ex a b f g = fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x () let raise0 (a:Type) (e:exn) : ex a = fun _ -> Inr e (* Define the new effect using DM4F *) total reifiable reflectable new_effect { EXN : (a:Type) -> Effect with repr = ex ; bind = bind_ex ; return = return_ex ; raise (#a:Type) = raise0 a } let raise = EXN?.raise (* An effect to alias easily write pre- and postconditions *) (* Note: we use Type0 instead of EXN?.pre to avoid having to thunk everything. *) effect Exn (a:Type) (pre:Type0) (post:EXN?.post a) = EXN a (fun (_:unit) (p:EXN?.post a) -> pre /\ (forall (r:either a exn). (pre /\ post r) ==> p r)) (* Another alias. Ex a is the effect type for total exception-throwing * programs. i.e. Any program of type `Ex a´ will throw or finish * correctly, but never loop. *) effect Ex (a:Type) = EXN a (fun _ p -> forall x. p x) (* * We now show `div´ to be correct in two ways. The property we show is * that if `div´ throws, then the divisor was zero; and if it doesn't, * then the divisor was not zero and the result (z) is the division of i * and j. * * In the first definition, we give a strong type to `div´: we make use * of `Exn´ to give pre- and postconditions to the function, specifying * the property we want. This is known as an intrinsic proof: it's * within the definition. * * In the second, we give a very lax type to div, namely `Ex int´ (note * it is different from Exn). This type is only implying that calling * div will either throw an exception or return an int, but there's no * specification about the result or about when exceptions occur. * * As `Ex´ is a effect, we can reason about `div´ outside of * its definition by turning it into a pure function. This is what is * done in the `lemma_div_extrinsic´ lemma. * * For primitive effects, this is impossible since logical properties * (in proof-irrelevant contexts) only make sense for pure and total * terms, so one is only able to do proofs intrinsically. *) exception Division_by_zero val div_intrinsic : i:nat -> j:int -> Exn int (requires True) (ensures (function | Inr Division_by_zero -> j=0 | Inl z -> j<>0 /\ z = i / j | _ -> True)) let div_intrinsic i j = if j=0 then raise Division_by_zero else i / j
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat -> j: Prims.int -> FStar.DM4F.Exceptions.Ex Prims.int
FStar.DM4F.Exceptions.Ex
[]
[]
[ "Prims.nat", "Prims.int", "Prims.op_Equality", "FStar.DM4F.Exceptions.raise", "FStar.DM4F.Exceptions.Division_by_zero", "Prims.bool", "Prims.op_Division" ]
[]
false
true
false
false
false
let div_extrinsic (i: nat) (j: int) : Ex int =
if j = 0 then raise Division_by_zero else i / j
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.raise_
val raise_ : a:Type -> e:exn -> Tot (EXN?.repr a (fun (_:unit) (p:EXN?.post a) -> p (Inr e)))
val raise_ : a:Type -> e:exn -> Tot (EXN?.repr a (fun (_:unit) (p:EXN?.post a) -> p (Inr e)))
let raise_ a (e:exn) (_:unit) = Inr e
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 117, "start_col": 0, "start_line": 117 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> ex a let return_ex a x = fun _ -> Inl x val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b let bind_ex a b f g = fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x () let raise0 (a:Type) (e:exn) : ex a = fun _ -> Inr e (* Define the new effect using DM4F *) total reifiable reflectable new_effect { EXN : (a:Type) -> Effect with repr = ex ; bind = bind_ex ; return = return_ex ; raise (#a:Type) = raise0 a } let raise = EXN?.raise (* An effect to alias easily write pre- and postconditions *) (* Note: we use Type0 instead of EXN?.pre to avoid having to thunk everything. *) effect Exn (a:Type) (pre:Type0) (post:EXN?.post a) = EXN a (fun (_:unit) (p:EXN?.post a) -> pre /\ (forall (r:either a exn). (pre /\ post r) ==> p r)) (* Another alias. Ex a is the effect type for total exception-throwing * programs. i.e. Any program of type `Ex a´ will throw or finish * correctly, but never loop. *) effect Ex (a:Type) = EXN a (fun _ p -> forall x. p x) (* * We now show `div´ to be correct in two ways. The property we show is * that if `div´ throws, then the divisor was zero; and if it doesn't, * then the divisor was not zero and the result (z) is the division of i * and j. * * In the first definition, we give a strong type to `div´: we make use * of `Exn´ to give pre- and postconditions to the function, specifying * the property we want. This is known as an intrinsic proof: it's * within the definition. * * In the second, we give a very lax type to div, namely `Ex int´ (note * it is different from Exn). This type is only implying that calling * div will either throw an exception or return an int, but there's no * specification about the result or about when exceptions occur. * * As `Ex´ is a effect, we can reason about `div´ outside of * its definition by turning it into a pure function. This is what is * done in the `lemma_div_extrinsic´ lemma. * * For primitive effects, this is impossible since logical properties * (in proof-irrelevant contexts) only make sense for pure and total * terms, so one is only able to do proofs intrinsically. *) exception Division_by_zero val div_intrinsic : i:nat -> j:int -> Exn int (requires True) (ensures (function | Inr Division_by_zero -> j=0 | Inl z -> j<>0 /\ z = i / j | _ -> True)) let div_intrinsic i j = if j=0 then raise Division_by_zero else i / j let div_extrinsic (i:nat) (j:int) : Ex int = if j=0 then raise Division_by_zero else i / j let lemma_div_extrinsic (i:nat) (j:int) : Lemma (match reify (div_extrinsic i j) () with | Inr Division_by_zero -> j = 0 | Inl z -> j <> 0 /\ z = i / j) = () (* * We can also build a new action "on the fly" using reflect! * Here we define raise_ as a pure function working with the * representation of Ex. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> e: Prims.exn -> FStar.DM4F.Exceptions._dm4f_EXN_repr a (fun _ p -> p (FStar.Pervasives.Inr e))
Prims.Tot
[ "total" ]
[]
[ "Prims.exn", "Prims.unit", "FStar.Pervasives.Inr", "FStar.Pervasives.either" ]
[]
false
false
false
false
false
let raise_ a (e: exn) (_: unit) =
Inr e
false
FStar.DM4F.Exceptions.fst
FStar.DM4F.Exceptions.raise__
val raise__ (a: Type) (e: exn) : Exn a True (fun r -> r == Inr e)
val raise__ (a: Type) (e: exn) : Exn a True (fun r -> r == Inr e)
let raise__ (a:Type) (e:exn) : Exn a True (fun r -> r == Inr e) = EXN?.reflect (raise_ a e)
{ "file_name": "examples/dm4free/FStar.DM4F.Exceptions.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 121, "start_col": 1, "start_line": 120 }
(* 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.DM4F.Exceptions (********************************************************** * Dijkstra Monads for Free : Exceptions * * Example of an exception monad effect, with a lift from * the Pure effect into it and an example of how both * intrinsic and extrinsic proof methods can be used * on a simple division function. * **********************************************************) (* The underlying representation type *) let ex (a:Type) = unit -> M (either a exn) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> ex a let return_ex a x = fun _ -> Inl x val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> ex b) -> ex b let bind_ex a b f g = fun _ -> let r = f () in match r with | Inr e -> Inr e | Inl x -> g x () let raise0 (a:Type) (e:exn) : ex a = fun _ -> Inr e (* Define the new effect using DM4F *) total reifiable reflectable new_effect { EXN : (a:Type) -> Effect with repr = ex ; bind = bind_ex ; return = return_ex ; raise (#a:Type) = raise0 a } let raise = EXN?.raise (* An effect to alias easily write pre- and postconditions *) (* Note: we use Type0 instead of EXN?.pre to avoid having to thunk everything. *) effect Exn (a:Type) (pre:Type0) (post:EXN?.post a) = EXN a (fun (_:unit) (p:EXN?.post a) -> pre /\ (forall (r:either a exn). (pre /\ post r) ==> p r)) (* Another alias. Ex a is the effect type for total exception-throwing * programs. i.e. Any program of type `Ex a´ will throw or finish * correctly, but never loop. *) effect Ex (a:Type) = EXN a (fun _ p -> forall x. p x) (* * We now show `div´ to be correct in two ways. The property we show is * that if `div´ throws, then the divisor was zero; and if it doesn't, * then the divisor was not zero and the result (z) is the division of i * and j. * * In the first definition, we give a strong type to `div´: we make use * of `Exn´ to give pre- and postconditions to the function, specifying * the property we want. This is known as an intrinsic proof: it's * within the definition. * * In the second, we give a very lax type to div, namely `Ex int´ (note * it is different from Exn). This type is only implying that calling * div will either throw an exception or return an int, but there's no * specification about the result or about when exceptions occur. * * As `Ex´ is a effect, we can reason about `div´ outside of * its definition by turning it into a pure function. This is what is * done in the `lemma_div_extrinsic´ lemma. * * For primitive effects, this is impossible since logical properties * (in proof-irrelevant contexts) only make sense for pure and total * terms, so one is only able to do proofs intrinsically. *) exception Division_by_zero val div_intrinsic : i:nat -> j:int -> Exn int (requires True) (ensures (function | Inr Division_by_zero -> j=0 | Inl z -> j<>0 /\ z = i / j | _ -> True)) let div_intrinsic i j = if j=0 then raise Division_by_zero else i / j let div_extrinsic (i:nat) (j:int) : Ex int = if j=0 then raise Division_by_zero else i / j let lemma_div_extrinsic (i:nat) (j:int) : Lemma (match reify (div_extrinsic i j) () with | Inr Division_by_zero -> j = 0 | Inl z -> j <> 0 /\ z = i / j) = () (* * We can also build a new action "on the fly" using reflect! * Here we define raise_ as a pure function working with the * representation of Ex. *) val raise_ : a:Type -> e:exn -> Tot (EXN?.repr a (fun (_:unit) (p:EXN?.post a) -> p (Inr e))) let raise_ a (e:exn) (_:unit) = Inr e
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Exceptions.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> e: Prims.exn -> FStar.DM4F.Exceptions.Exn a
FStar.DM4F.Exceptions.Exn
[]
[]
[ "Prims.exn", "FStar.DM4F.Exceptions.raise_", "Prims.l_True", "FStar.Pervasives.either", "Prims.eq2", "FStar.Pervasives.Inr" ]
[]
false
true
false
false
false
let raise__ (a: Type) (e: exn) : Exn a True (fun r -> r == Inr e) =
EXN?.reflect (raise_ a e)
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test1_expected_sha2_224
val test1_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
val test1_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 71, "start_col": 0, "start_line": 63 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (28ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_expected_sha2_224:b: lbuffer uint8 28ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7 ]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test1_plaintext
val test1_plaintext:b: lbuffer uint8 3ul {recallable b}
val test1_plaintext:b: lbuffer uint8 3ul {recallable b}
let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 61, "start_col": 0, "start_line": 54 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (3ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_plaintext:b: lbuffer uint8 3ul {recallable b} =
let open Lib.RawIntTypes in [@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.u8
val u8: n:nat{n < 0x100} -> uint8
val u8: n:nat{n < 0x100} -> uint8
let u8 n = u8 n
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 49, "start_col": 0, "start_line": 49 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Prims.nat{n < 0x100} -> Lib.IntTypes.uint8
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.u8", "Lib.IntTypes.uint8" ]
[]
false
false
false
false
false
let u8 n =
u8 n
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test2_plaintext
val test2_plaintext:b: lbuffer uint8 0ul {recallable b}
val test2_plaintext:b: lbuffer uint8 0ul {recallable b}
let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 115, "start_col": 0, "start_line": 109 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (0ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_plaintext:b: lbuffer uint8 0ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test3_expected_sha2_256
val test3_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
val test3_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
let test3_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x8d; 0x6a; 0x61; 0xd2; 0x06; 0x38; 0xb8; 0xe5; 0xc0; 0x26; 0x93; 0x0c; 0x3e; 0x60; 0x39; 0xa3; 0x3c; 0xe4; 0x59; 0x64; 0xff; 0x21; 0x67; 0xf6; 0xec; 0xed; 0xd4; 0x19; 0xdb; 0x06; 0xc1]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 193, "start_col": 0, "start_line": 185 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA2 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x75; 0x38; 0x8b; 0x16; 0x51; 0x27; 0x76; 0xcc; 0x5d; 0xba; 0x5d; 0xa1; 0xfd; 0x89; 0x01; 0x50; 0xb0; 0xc6; 0x45; 0x5c; 0xb4; 0xf5; 0x8b; 0x19; 0x52; 0x52; 0x25; 0x25]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (32ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test3_expected_sha2_256:b: lbuffer uint8 32ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x24; 0x8d; 0x6a; 0x61; 0xd2; 0x06; 0x38; 0xb8; 0xe5; 0xc0; 0x26; 0x93; 0x0c; 0x3e; 0x60; 0x39; 0xa3; 0x3c; 0xe4; 0x59; 0x64; 0xff; 0x21; 0x67; 0xf6; 0xec; 0xed; 0xd4; 0x19; 0xdb; 0x06; 0xc1 ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test2_expected_sha2_256
val test2_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
val test2_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 135, "start_col": 0, "start_line": 127 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (32ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_expected_sha2_256:b: lbuffer uint8 32ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55 ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test1_expected_sha2_384
val test1_expected_sha2_384:b: lbuffer uint8 48ul {recallable b}
val test1_expected_sha2_384:b: lbuffer uint8 48ul {recallable b}
let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 92, "start_col": 0, "start_line": 83 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (48ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_expected_sha2_384:b: lbuffer uint8 48ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7 ]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test3_plaintext
val test3_plaintext:b: lbuffer uint8 56ul {recallable b}
val test3_plaintext:b: lbuffer uint8 56ul {recallable b}
let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 173, "start_col": 0, "start_line": 163 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (56ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test3_plaintext:b: lbuffer uint8 56ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71 ]) in assert_norm (List.Tot.length l == 56); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test1_expected_sha2_512
val test1_expected_sha2_512:b: lbuffer uint8 64ul {recallable b}
val test1_expected_sha2_512:b: lbuffer uint8 64ul {recallable b}
let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 104, "start_col": 0, "start_line": 94 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (64ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_expected_sha2_512:b: lbuffer uint8 64ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f ]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test2_expected_sha2_384
val test2_expected_sha2_384:b: lbuffer uint8 48ul {recallable b}
val test2_expected_sha2_384:b: lbuffer uint8 48ul {recallable b}
let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 146, "start_col": 0, "start_line": 137 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (48ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_expected_sha2_384:b: lbuffer uint8 48ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b ]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test3_expected_sha2_224
val test3_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
val test3_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
let test3_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x75; 0x38; 0x8b; 0x16; 0x51; 0x27; 0x76; 0xcc; 0x5d; 0xba; 0x5d; 0xa1; 0xfd; 0x89; 0x01; 0x50; 0xb0; 0xc6; 0x45; 0x5c; 0xb4; 0xf5; 0x8b; 0x19; 0x52; 0x52; 0x25; 0x25]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 183, "start_col": 0, "start_line": 175 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA2 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (28ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test3_expected_sha2_224:b: lbuffer uint8 28ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0x75; 0x38; 0x8b; 0x16; 0x51; 0x27; 0x76; 0xcc; 0x5d; 0xba; 0x5d; 0xa1; 0xfd; 0x89; 0x01; 0x50; 0xb0; 0xc6; 0x45; 0x5c; 0xb4; 0xf5; 0x8b; 0x19; 0x52; 0x52; 0x25; 0x25 ]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test2_expected_sha2_224
val test2_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
val test2_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 125, "start_col": 0, "start_line": 117 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (28ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_expected_sha2_224:b: lbuffer uint8 28ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f ]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.associative
val associative : equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 69, "start_col": 0, "start_line": 67 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.logical" ]
[]
false
false
false
true
true
let associative #a (equals: (a -> a -> prop)) (f: (a -> a -> a)) =
forall x y z. (f x (f y z)) `equals` (f (f x y) z)
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.symmetry
val symmetry : equals: (_: a -> _: a -> Prims.prop) -> Prims.logical
let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 62, "start_col": 0, "start_line": 60 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
equals: (_: a -> _: a -> Prims.prop) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.l_imp", "Prims.logical" ]
[]
false
false
false
true
true
let symmetry #a (equals: (a -> a -> prop)) =
forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test2_expected_sha2_512
val test2_expected_sha2_512:b: lbuffer uint8 64ul {recallable b}
val test2_expected_sha2_512:b: lbuffer uint8 64ul {recallable b}
let test2_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 158, "start_col": 0, "start_line": 148 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (64ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test2_expected_sha2_512:b: lbuffer uint8 64ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e ]) in assert_norm (List.Tot.length l == 64); createL_mglobal l
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.transitive
val transitive : equals: (_: a -> _: a -> Prims.prop) -> Prims.logical
let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 65, "start_col": 0, "start_line": 64 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
equals: (_: a -> _: a -> Prims.prop) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.logical" ]
[]
false
false
false
true
true
let transitive #a (equals: (a -> a -> prop)) =
forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.commutative
val commutative : equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 73, "start_col": 0, "start_line": 71 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.logical" ]
[]
false
false
false
true
true
let commutative #a (equals: (a -> a -> prop)) (f: (a -> a -> a)) =
forall x y. {:pattern f x y} (f x y) `equals` (f y x)
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.fp_heap_0
val fp_heap_0 : interp: (_: hprop -> _: heap -> Prims.prop) -> pre: hprop -> Type
let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h}
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 89, "start_col": 0, "start_line": 83 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
interp: (_: hprop -> _: heap -> Prims.prop) -> pre: hprop -> Type
Prims.Tot
[ "total" ]
[]
[ "Prims.prop" ]
[]
false
false
false
true
true
let fp_heap_0 (#heap #hprop: Type) (interp: (hprop -> heap -> prop)) (pre: hprop) =
h: heap{interp pre h}
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.is_unit
val is_unit : x: a -> equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 78, "start_col": 0, "start_line": 75 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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: a -> equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.l_and", "Prims.logical" ]
[]
false
false
false
true
true
let is_unit #a (x: a) (equals: (a -> a -> prop)) (f: (a -> a -> a)) =
forall y. {:pattern f x y\/f y x} (f x y) `equals` y /\ (f y x) `equals` y
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.equals_ext
val equals_ext : equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 59, "end_line": 81, "start_col": 0, "start_line": 80 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
equals: (_: a -> _: a -> Prims.prop) -> f: (_: a -> _: a -> a) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.l_imp", "Prims.logical" ]
[]
false
false
false
true
true
let equals_ext #a (equals: (a -> a -> prop)) (f: (a -> a -> a)) =
forall x1 x2 y. x1 `equals` x2 ==> (f x1 y) `equals` (f x2 y)
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test4_expected_sha2_224
val test4_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
val test4_expected_sha2_224:b: lbuffer uint8 28ul {recallable b}
let test4_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xc9; 0x7c; 0xa9; 0xa5; 0x59; 0x85; 0x0c; 0xe9; 0x7a; 0x04; 0xa9; 0x6d; 0xef; 0x6d; 0x99; 0xa9; 0xe0; 0xe0; 0xe2; 0xab; 0x14; 0xe6; 0xb8; 0xdf; 0x26; 0x5f; 0xc0; 0xb3]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 244, "start_col": 0, "start_line": 236 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA2 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x75; 0x38; 0x8b; 0x16; 0x51; 0x27; 0x76; 0xcc; 0x5d; 0xba; 0x5d; 0xa1; 0xfd; 0x89; 0x01; 0x50; 0xb0; 0xc6; 0x45; 0x5c; 0xb4; 0xf5; 0x8b; 0x19; 0x52; 0x52; 0x25; 0x25]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x8d; 0x6a; 0x61; 0xd2; 0x06; 0x38; 0xb8; 0xe5; 0xc0; 0x26; 0x93; 0x0c; 0x3e; 0x60; 0x39; 0xa3; 0x3c; 0xe4; 0x59; 0x64; 0xff; 0x21; 0x67; 0xf6; 0xec; 0xed; 0xd4; 0x19; 0xdb; 0x06; 0xc1]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x33; 0x91; 0xfd; 0xdd; 0xfc; 0x8d; 0xc7; 0x39; 0x37; 0x07; 0xa6; 0x5b; 0x1b; 0x47; 0x09; 0x39; 0x7c; 0xf8; 0xb1; 0xd1; 0x62; 0xaf; 0x05; 0xab; 0xfe; 0x8f; 0x45; 0x0d; 0xe5; 0xf3; 0x6b; 0xc6; 0xb0; 0x45; 0x5a; 0x85; 0x20; 0xbc; 0x4e; 0x6f; 0x5f; 0xe9; 0x5b; 0x1f; 0xe3; 0xc8; 0x45; 0x2b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x20; 0x4a; 0x8f; 0xc6; 0xdd; 0xa8; 0x2f; 0x0a; 0x0c; 0xed; 0x7b; 0xeb; 0x8e; 0x08; 0xa4; 0x16; 0x57; 0xc1; 0x6e; 0xf4; 0x68; 0xb2; 0x28; 0xa8; 0x27; 0x9b; 0xe3; 0x31; 0xa7; 0x03; 0xc3; 0x35; 0x96; 0xfd; 0x15; 0xc1; 0x3b; 0x1b; 0x07; 0xf9; 0xaa; 0x1d; 0x3b; 0xea; 0x57; 0x78; 0x9c; 0xa0; 0x31; 0xad; 0x85; 0xc7; 0xa7; 0x1d; 0xd7; 0x03; 0x54; 0xec; 0x63; 0x12; 0x38; 0xca; 0x34; 0x45]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA2 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (28ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test4_expected_sha2_224:b: lbuffer uint8 28ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xc9; 0x7c; 0xa9; 0xa5; 0x59; 0x85; 0x0c; 0xe9; 0x7a; 0x04; 0xa9; 0x6d; 0xef; 0x6d; 0x99; 0xa9; 0xe0; 0xe0; 0xe2; 0xab; 0x14; 0xe6; 0xb8; 0xdf; 0x26; 0x5f; 0xc0; 0xb3 ]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.depends_only_on_0
val depends_only_on_0 : interp: (_: hprop -> _: heap -> Prims.prop) -> disjoint: (_: heap -> _: heap -> Prims.prop) -> join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap) -> q: (_: heap -> Prims.prop) -> fp: hprop -> Prims.logical
let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1)
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 85, "end_line": 99, "start_col": 0, "start_line": 91 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
interp: (_: hprop -> _: heap -> Prims.prop) -> disjoint: (_: heap -> _: heap -> Prims.prop) -> join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap) -> q: (_: heap -> Prims.prop) -> fp: hprop -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Steel.Semantics.Hoare.MST.fp_heap_0", "Prims.l_iff", "Prims.logical" ]
[]
false
false
false
false
true
let depends_only_on_0 (#heap #hprop: Type) (interp: (hprop -> heap -> prop)) (disjoint: (heap -> heap -> prop)) (join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap)) (q: (heap -> prop)) (fp: hprop) =
forall (h0: fp_heap_0 interp fp) (h1: heap{disjoint h0 h1}). q h0 <==> q (join h0 h1)
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test1_expected_sha2_256
val test1_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
val test1_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 81, "start_col": 0, "start_line": 73 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (32ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test1_expected_sha2_256:b: lbuffer uint8 32ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.disjoint_sym
val disjoint_sym : st: Steel.Semantics.Hoare.MST.st0 -> Prims.logical
let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 136, "start_col": 0, "start_line": 135 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
st: Steel.Semantics.Hoare.MST.st0 -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Steel.Semantics.Hoare.MST.st0", "Prims.l_Forall", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Prims.l_iff", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__disjoint", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_sym (st: st0) =
forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.interp_extensionality
val interp_extensionality : equals: (_: r -> _: r -> Prims.prop) -> f: (_: r -> _: s -> Prims.prop) -> Prims.logical
let interp_extensionality #r #s (equals:r -> r -> prop) (f:r -> s -> prop) = forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 74, "end_line": 161, "start_col": 0, "start_line": 160 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0 let disjoint_join (st:st0) = forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.disjoint m0 m1 /\ st.disjoint m0 m2 /\ st.disjoint (st.join m0 m1) m2 /\ st.disjoint (st.join m0 m2) m1 let join_commutative (st:st0 { disjoint_sym st }) = forall m0 m1. st.disjoint m0 m1 ==> st.join m0 m1 == st.join m1 m0 let join_associative (st:st0{disjoint_join st})= forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.join m0 (st.join m1 m2) == st.join (st.join m0 m1) m2 ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
equals: (_: r -> _: r -> Prims.prop) -> f: (_: r -> _: s -> Prims.prop) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.logical" ]
[]
false
false
false
true
true
let interp_extensionality #r #s (equals: (r -> r -> prop)) (f: (r -> s -> prop)) =
forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.fp_prop_0
val fp_prop_0 : interp: (_: hprop -> _: heap -> Prims.prop) -> disjoint: (_: heap -> _: heap -> Prims.prop) -> join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap) -> fp: hprop -> Type
let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp}
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 109, "start_col": 0, "start_line": 101 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
interp: (_: hprop -> _: heap -> Prims.prop) -> disjoint: (_: heap -> _: heap -> Prims.prop) -> join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap) -> fp: hprop -> Type
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Steel.Semantics.Hoare.MST.depends_only_on_0" ]
[]
false
false
false
false
true
let fp_prop_0 (#heap #hprop: Type) (interp: (hprop -> heap -> prop)) (disjoint: (heap -> heap -> prop)) (join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap)) (fp: hprop) =
p: (heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp}
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.fp_prop
val fp_prop : fp: Mkst0?.hprop st -> Type
let fp_prop (#st:st0) (fp:st.hprop) = fp_prop_0 st.interp st.disjoint st.join fp
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 44, "end_line": 173, "start_col": 0, "start_line": 172 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0 let disjoint_join (st:st0) = forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.disjoint m0 m1 /\ st.disjoint m0 m2 /\ st.disjoint (st.join m0 m1) m2 /\ st.disjoint (st.join m0 m2) m1 let join_commutative (st:st0 { disjoint_sym st }) = forall m0 m1. st.disjoint m0 m1 ==> st.join m0 m1 == st.join m1 m0 let join_associative (st:st0{disjoint_join st})= forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.join m0 (st.join m1 m2) == st.join (st.join m0 m1) m2 //////////////////////////////////////////////////////////////////////////////// let interp_extensionality #r #s (equals:r -> r -> prop) (f:r -> s -> prop) = forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h let affine (st:st0) = forall r0 r1 s. {:pattern (st.interp (r0 `st.star` r1) s) } st.interp (r0 `st.star` r1) s ==> st.interp r0 s //////////////////////////////////////////////////////////////////////////////// let depends_only_on (#st:st0) (q:st.mem -> prop) (fp: st.hprop) = depends_only_on_0 st.interp st.disjoint st.join q fp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
fp: Mkst0?.hprop st -> Type
Prims.Tot
[ "total" ]
[]
[ "Steel.Semantics.Hoare.MST.st0", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__hprop", "Steel.Semantics.Hoare.MST.fp_prop_0", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__interp", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__disjoint", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__join" ]
[]
false
false
false
false
true
let fp_prop (#st: st0) (fp: st.hprop) =
fp_prop_0 st.interp st.disjoint st.join fp
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.st
val st : Type
let st = s:st0 { st_laws s }
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 201, "start_col": 0, "start_line": 201 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0 let disjoint_join (st:st0) = forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.disjoint m0 m1 /\ st.disjoint m0 m2 /\ st.disjoint (st.join m0 m1) m2 /\ st.disjoint (st.join m0 m2) m1 let join_commutative (st:st0 { disjoint_sym st }) = forall m0 m1. st.disjoint m0 m1 ==> st.join m0 m1 == st.join m1 m0 let join_associative (st:st0{disjoint_join st})= forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.join m0 (st.join m1 m2) == st.join (st.join m0 m1) m2 //////////////////////////////////////////////////////////////////////////////// let interp_extensionality #r #s (equals:r -> r -> prop) (f:r -> s -> prop) = forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h let affine (st:st0) = forall r0 r1 s. {:pattern (st.interp (r0 `st.star` r1) s) } st.interp (r0 `st.star` r1) s ==> st.interp r0 s //////////////////////////////////////////////////////////////////////////////// let depends_only_on (#st:st0) (q:st.mem -> prop) (fp: st.hprop) = depends_only_on_0 st.interp st.disjoint st.join q fp let fp_prop (#st:st0) (fp:st.hprop) = fp_prop_0 st.interp st.disjoint st.join fp let lemma_weaken_depends_only_on (#st:st0{affine st}) (fp0 fp1:st.hprop) (q:fp_prop fp0) : Lemma (q `depends_only_on` (fp0 `st.star` fp1)) = () let st_laws (st:st0) = (* standard laws about the equality relation *) symmetry st.equals /\ transitive st.equals /\ interp_extensionality st.equals st.interp /\ (* standard laws for star forming a CM *) associative st.equals st.star /\ commutative st.equals st.star /\ is_unit st.emp st.equals st.star /\ equals_ext st.equals st.star /\ (* We're working in an affine interpretation of SL *) affine st /\ (* laws about disjoint and join *) disjoint_sym st /\ disjoint_join st /\ join_commutative st /\ join_associative st
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
Type
Prims.Tot
[ "total" ]
[]
[ "Steel.Semantics.Hoare.MST.st0", "Steel.Semantics.Hoare.MST.st_laws" ]
[]
false
false
false
true
true
let st =
s: st0{st_laws s}
false
Hacl.Test.SHA2.fst
Hacl.Test.SHA2.test4_expected_sha2_256
val test4_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
val test4_expected_sha2_256:b: lbuffer uint8 32ul {recallable b}
let test4_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x5b; 0x16; 0xa7; 0x78; 0xaf; 0x83; 0x80; 0x03; 0x6c; 0xe5; 0x9e; 0x7b; 0x04; 0x92; 0x37; 0x0b; 0x24; 0x9b; 0x11; 0xe8; 0xf0; 0x7a; 0x51; 0xaf; 0xac; 0x45; 0x03; 0x7a; 0xfe; 0xe9; 0xd1]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
{ "file_name": "code/tests/Hacl.Test.SHA2.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 254, "start_col": 0, "start_line": 246 }
module Hacl.Test.SHA2 open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.PrintBuffer open Hacl.Streaming.SHA2 open Hacl.Hash.SHA2 #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val test_sha2: msg_len:size_t -> msg:lbuffer uint8 msg_len -> expected224:lbuffer uint8 28ul -> expected256:lbuffer uint8 32ul -> expected384:lbuffer uint8 48ul -> expected512:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h msg /\ live h expected224 /\ live h expected256 /\ live h expected384 /\ live h expected512) (ensures fun h0 r h1 -> True) let test_sha2 msg_len msg expected224 expected256 expected384 expected512 = Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; push_frame(); let test224 = create 28ul (u8 0) in let test256 = create 32ul (u8 0) in let test384 = create 48ul (u8 0) in let test512 = create 64ul (u8 0) in hash_224 (test224 <: lbuffer uint8 28ul) msg msg_len; hash_256 (test256 <: lbuffer uint8 32ul) msg msg_len; hash_384 (test384 <: lbuffer uint8 48ul) msg msg_len; hash_512 (test512 <: lbuffer uint8 64ul) msg msg_len; if not (result_compare_display 28ul (to_const test224) (to_const expected224)) then C.exit 255l; if not (result_compare_display 32ul (to_const test256) (to_const expected256)) then C.exit 255l; if not (result_compare_display 48ul (to_const test384) (to_const expected384)) then C.exit 255l; if not (result_compare_display 64ul (to_const test512) (to_const expected512)) then C.exit 255l; pop_frame() inline_for_extraction noextract val u8: n:nat{n < 0x100} -> uint8 let u8 n = u8 n // // Test1_SHA2 // let test1_plaintext: b:lbuffer uint8 3ul{ recallable b } = let open Lib.RawIntTypes in [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63]) in assert_norm (List.Tot.length l == 3); createL_mglobal l let test1_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x23; 0x09; 0x7d; 0x22; 0x34; 0x05; 0xd8; 0x22; 0x86; 0x42; 0xa4; 0x77; 0xbd; 0xa2; 0x55; 0xb3; 0x2a; 0xad; 0xbc; 0xe4; 0xbd; 0xa0; 0xb3; 0xf7; 0xe3; 0x6c; 0x9d; 0xa7]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test1_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xba; 0x78; 0x16; 0xbf; 0x8f; 0x01; 0xcf; 0xea; 0x41; 0x41; 0x40; 0xde; 0x5d; 0xae; 0x22; 0x23; 0xb0; 0x03; 0x61; 0xa3; 0x96; 0x17; 0x7a; 0x9c; 0xb4; 0x10; 0xff; 0x61; 0xf2; 0x00; 0x15; 0xad]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test1_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcb; 0x00; 0x75; 0x3f; 0x45; 0xa3; 0x5e; 0x8b; 0xb5; 0xa0; 0x3d; 0x69; 0x9a; 0xc6; 0x50; 0x07; 0x27; 0x2c; 0x32; 0xab; 0x0e; 0xde; 0xd1; 0x63; 0x1a; 0x8b; 0x60; 0x5a; 0x43; 0xff; 0x5b; 0xed; 0x80; 0x86; 0x07; 0x2b; 0xa1; 0xe7; 0xcc; 0x23; 0x58; 0xba; 0xec; 0xa1; 0x34; 0xc8; 0x25; 0xa7]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test1_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xdd; 0xaf; 0x35; 0xa1; 0x93; 0x61; 0x7a; 0xba; 0xcc; 0x41; 0x73; 0x49; 0xae; 0x20; 0x41; 0x31; 0x12; 0xe6; 0xfa; 0x4e; 0x89; 0xa9; 0x7e; 0xa2; 0x0a; 0x9e; 0xee; 0xe6; 0x4b; 0x55; 0xd3; 0x9a; 0x21; 0x92; 0x99; 0x2a; 0x27; 0x4f; 0xc1; 0xa8; 0x36; 0xba; 0x3c; 0x23; 0xa3; 0xfe; 0xeb; 0xbd; 0x45; 0x4d; 0x44; 0x23; 0x64; 0x3c; 0xe8; 0x0e; 0x2a; 0x9a; 0xc9; 0x4f; 0xa5; 0x4c; 0xa4; 0x9f]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test2_SHA2 // let test2_plaintext: b:lbuffer uint8 0ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 []) in assert_norm (List.Tot.length l == 0); createL_mglobal l let test2_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xd1; 0x4a; 0x02; 0x8c; 0x2a; 0x3a; 0x2b; 0xc9; 0x47; 0x61; 0x02; 0xbb; 0x28; 0x82; 0x34; 0xc4; 0x15; 0xa2; 0xb0; 0x1f; 0x82; 0x8e; 0xa6; 0x2a; 0xc5; 0xb3; 0xe4; 0x2f]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test2_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xe3; 0xb0; 0xc4; 0x42; 0x98; 0xfc; 0x1c; 0x14; 0x9a; 0xfb; 0xf4; 0xc8; 0x99; 0x6f; 0xb9; 0x24; 0x27; 0xae; 0x41; 0xe4; 0x64; 0x9b; 0x93; 0x4c; 0xa4; 0x95; 0x99; 0x1b; 0x78; 0x52; 0xb8; 0x55]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test2_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x38; 0xb0; 0x60; 0xa7; 0x51; 0xac; 0x96; 0x38; 0x4c; 0xd9; 0x32; 0x7e; 0xb1; 0xb1; 0xe3; 0x6a; 0x21; 0xfd; 0xb7; 0x11; 0x14; 0xbe; 0x07; 0x43; 0x4c; 0x0c; 0xc7; 0xbf; 0x63; 0xf6; 0xe1; 0xda; 0x27; 0x4e; 0xde; 0xbf; 0xe7; 0x6f; 0x65; 0xfb; 0xd5; 0x1a; 0xd2; 0xf1; 0x48; 0x98; 0xb9; 0x5b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test2_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xcf; 0x83; 0xe1; 0x35; 0x7e; 0xef; 0xb8; 0xbd; 0xf1; 0x54; 0x28; 0x50; 0xd6; 0x6d; 0x80; 0x07; 0xd6; 0x20; 0xe4; 0x05; 0x0b; 0x57; 0x15; 0xdc; 0x83; 0xf4; 0xa9; 0x21; 0xd3; 0x6c; 0xe9; 0xce; 0x47; 0xd0; 0xd1; 0x3c; 0x5d; 0x85; 0xf2; 0xb0; 0xff; 0x83; 0x18; 0xd2; 0x87; 0x7e; 0xec; 0x2f; 0x63; 0xb9; 0x31; 0xbd; 0x47; 0x41; 0x7a; 0x81; 0xa5; 0x38; 0x32; 0x7a; 0xf9; 0x27; 0xda; 0x3e]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test3_SHA2 // let test3_plaintext: b:lbuffer uint8 56ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x62; 0x63; 0x64; 0x65; 0x63; 0x64; 0x65; 0x66; 0x64; 0x65; 0x66; 0x67; 0x65; 0x66; 0x67; 0x68; 0x66; 0x67; 0x68; 0x69; 0x67; 0x68; 0x69; 0x6a; 0x68; 0x69; 0x6a; 0x6b; 0x69; 0x6a; 0x6b; 0x6c; 0x6a; 0x6b; 0x6c; 0x6d; 0x6b; 0x6c; 0x6d; 0x6e; 0x6c; 0x6d; 0x6e; 0x6f; 0x6d; 0x6e; 0x6f; 0x70; 0x6e; 0x6f; 0x70; 0x71]) in assert_norm (List.Tot.length l == 56); createL_mglobal l let test3_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x75; 0x38; 0x8b; 0x16; 0x51; 0x27; 0x76; 0xcc; 0x5d; 0xba; 0x5d; 0xa1; 0xfd; 0x89; 0x01; 0x50; 0xb0; 0xc6; 0x45; 0x5c; 0xb4; 0xf5; 0x8b; 0x19; 0x52; 0x52; 0x25; 0x25]) in assert_norm (List.Tot.length l == 28); createL_mglobal l let test3_expected_sha2_256: b:lbuffer uint8 32ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x24; 0x8d; 0x6a; 0x61; 0xd2; 0x06; 0x38; 0xb8; 0xe5; 0xc0; 0x26; 0x93; 0x0c; 0x3e; 0x60; 0x39; 0xa3; 0x3c; 0xe4; 0x59; 0x64; 0xff; 0x21; 0x67; 0xf6; 0xec; 0xed; 0xd4; 0x19; 0xdb; 0x06; 0xc1]) in assert_norm (List.Tot.length l == 32); createL_mglobal l let test3_expected_sha2_384: b:lbuffer uint8 48ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x33; 0x91; 0xfd; 0xdd; 0xfc; 0x8d; 0xc7; 0x39; 0x37; 0x07; 0xa6; 0x5b; 0x1b; 0x47; 0x09; 0x39; 0x7c; 0xf8; 0xb1; 0xd1; 0x62; 0xaf; 0x05; 0xab; 0xfe; 0x8f; 0x45; 0x0d; 0xe5; 0xf3; 0x6b; 0xc6; 0xb0; 0x45; 0x5a; 0x85; 0x20; 0xbc; 0x4e; 0x6f; 0x5f; 0xe9; 0x5b; 0x1f; 0xe3; 0xc8; 0x45; 0x2b]) in assert_norm (List.Tot.length l == 48); createL_mglobal l let test3_expected_sha2_512: b:lbuffer uint8 64ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x20; 0x4a; 0x8f; 0xc6; 0xdd; 0xa8; 0x2f; 0x0a; 0x0c; 0xed; 0x7b; 0xeb; 0x8e; 0x08; 0xa4; 0x16; 0x57; 0xc1; 0x6e; 0xf4; 0x68; 0xb2; 0x28; 0xa8; 0x27; 0x9b; 0xe3; 0x31; 0xa7; 0x03; 0xc3; 0x35; 0x96; 0xfd; 0x15; 0xc1; 0x3b; 0x1b; 0x07; 0xf9; 0xaa; 0x1d; 0x3b; 0xea; 0x57; 0x78; 0x9c; 0xa0; 0x31; 0xad; 0x85; 0xc7; 0xa7; 0x1d; 0xd7; 0x03; 0x54; 0xec; 0x63; 0x12; 0x38; 0xca; 0x34; 0x45]) in assert_norm (List.Tot.length l == 64); createL_mglobal l // // Test4_SHA2 // let test4_plaintext: b:lbuffer uint8 112ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0x61; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x62; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x63; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x64; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x65; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x66; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x67; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x68; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x69; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x6a; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x6b; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x6c; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x6d; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x6e; 0x6f; 0x70; 0x71; 0x72; 0x73; 0x74; 0x75]) in assert_norm (List.Tot.length l == 112); createL_mglobal l let test4_expected_sha2_224: b:lbuffer uint8 28ul{ recallable b } = [@ inline_let] let l:list uint8 = normalize_term (List.Tot.map u8 [0xc9; 0x7c; 0xa9; 0xa5; 0x59; 0x85; 0x0c; 0xe9; 0x7a; 0x04; 0xa9; 0x6d; 0xef; 0x6d; 0x99; 0xa9; 0xe0; 0xe0; 0xe2; 0xab; 0x14; 0xe6; 0xb8; 0xdf; 0x26; 0x5f; 0xc0; 0xb3]) in assert_norm (List.Tot.length l == 28); createL_mglobal l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintBuffer.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Hash.SHA2.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.All.fst.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "Hacl.Test.SHA2.fst" }
[ { "abbrev": false, "full_module": "Hacl.Hash.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Lib.PrintBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
b: Lib.Buffer.lbuffer_t Lib.Buffer.MUT (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) (32ul <: FStar.UInt32.t) {Lib.Buffer.recallable b}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_mglobal", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.buffer", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.recallable", "Prims.list", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.map", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Test.SHA2.u8", "Prims.Cons", "Prims.Nil" ]
[]
false
false
false
false
false
let test4_expected_sha2_256:b: lbuffer uint8 32ul {recallable b} =
[@@ inline_let ]let l:list uint8 = normalize_term (List.Tot.map u8 [ 0xcf; 0x5b; 0x16; 0xa7; 0x78; 0xaf; 0x83; 0x80; 0x03; 0x6c; 0xe5; 0x9e; 0x7b; 0x04; 0x92; 0x37; 0x0b; 0x24; 0x9b; 0x11; 0xe8; 0xf0; 0x7a; 0x51; 0xaf; 0xac; 0x45; 0x03; 0x7a; 0xfe; 0xe9; 0xd1 ]) in assert_norm (List.Tot.length l == 32); createL_mglobal l
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.depends_only_on
val depends_only_on : q: (_: Mkst0?.mem st -> Prims.prop) -> fp: Mkst0?.hprop st -> Prims.logical
let depends_only_on (#st:st0) (q:st.mem -> prop) (fp: st.hprop) = depends_only_on_0 st.interp st.disjoint st.join q fp
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 170, "start_col": 0, "start_line": 169 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0 let disjoint_join (st:st0) = forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.disjoint m0 m1 /\ st.disjoint m0 m2 /\ st.disjoint (st.join m0 m1) m2 /\ st.disjoint (st.join m0 m2) m1 let join_commutative (st:st0 { disjoint_sym st }) = forall m0 m1. st.disjoint m0 m1 ==> st.join m0 m1 == st.join m1 m0 let join_associative (st:st0{disjoint_join st})= forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.join m0 (st.join m1 m2) == st.join (st.join m0 m1) m2 //////////////////////////////////////////////////////////////////////////////// let interp_extensionality #r #s (equals:r -> r -> prop) (f:r -> s -> prop) = forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h let affine (st:st0) = forall r0 r1 s. {:pattern (st.interp (r0 `st.star` r1) s) } st.interp (r0 `st.star` r1) s ==> st.interp r0 s ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
q: (_: Mkst0?.mem st -> Prims.prop) -> fp: Mkst0?.hprop st -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Steel.Semantics.Hoare.MST.st0", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Prims.prop", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__hprop", "Steel.Semantics.Hoare.MST.depends_only_on_0", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__interp", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__disjoint", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__join", "Prims.logical" ]
[]
false
false
false
false
true
let depends_only_on (#st: st0) (q: (st.mem -> prop)) (fp: st.hprop) =
depends_only_on_0 st.interp st.disjoint st.join q fp
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.affine
val affine : st: Steel.Semantics.Hoare.MST.st0 -> Prims.logical
let affine (st:st0) = forall r0 r1 s. {:pattern (st.interp (r0 `st.star` r1) s) } st.interp (r0 `st.star` r1) s ==> st.interp r0 s
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 52, "end_line": 165, "start_col": 0, "start_line": 163 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0 let disjoint_join (st:st0) = forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.disjoint m0 m1 /\ st.disjoint m0 m2 /\ st.disjoint (st.join m0 m1) m2 /\ st.disjoint (st.join m0 m2) m1 let join_commutative (st:st0 { disjoint_sym st }) = forall m0 m1. st.disjoint m0 m1 ==> st.join m0 m1 == st.join m1 m0 let join_associative (st:st0{disjoint_join st})= forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.join m0 (st.join m1 m2) == st.join (st.join m0 m1) m2 //////////////////////////////////////////////////////////////////////////////// let interp_extensionality #r #s (equals:r -> r -> prop) (f:r -> s -> prop) = forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
st: Steel.Semantics.Hoare.MST.st0 -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Steel.Semantics.Hoare.MST.st0", "Prims.l_Forall", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__hprop", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__mem", "Prims.l_imp", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__interp", "Steel.Semantics.Hoare.MST.__proj__Mkst0__item__star", "Prims.logical" ]
[]
false
false
false
true
true
let affine (st: st0) =
forall r0 r1 s. {:pattern (st.interp (r0 `st.star` r1) s)} st.interp (r0 `st.star` r1) s ==> st.interp r0 s
false
Hacl.HPKE.Interface.HKDF.fst
Hacl.HPKE.Interface.HKDF.hkdf_extract256
val hkdf_extract256:HK.extract_st Hash.SHA2_256
val hkdf_extract256:HK.extract_st Hash.SHA2_256
let hkdf_extract256 : HK.extract_st Hash.SHA2_256 = Hacl.HKDF.extract_sha2_256
{ "file_name": "code/hpke/Hacl.HPKE.Interface.HKDF.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 78, "end_line": 26, "start_col": 0, "start_line": 26 }
module Hacl.HPKE.Interface.HKDF module S = Spec.Agile.HPKE module HK = Hacl.HKDF module Hash = Spec.Agile.Hash [@ Meta.Attribute.specialize ] noextract assume val hkdf_extract: #cs:S.ciphersuite -> HK.extract_st (S.hash_of_cs cs) [@ Meta.Attribute.specialize ] noextract assume val hkdf_expand: #cs:S.ciphersuite -> HK.expand_st (S.hash_of_cs cs) [@ Meta.Attribute.specialize ] noextract assume val hkdf_extract_kem: #cs:S.ciphersuite -> HK.extract_st (S.kem_hash_of_cs cs) [@ Meta.Attribute.specialize ] noextract assume val hkdf_expand_kem: #cs:S.ciphersuite -> HK.expand_st (S.kem_hash_of_cs cs) (** Instantiations of hkdf **)
{ "checked_file": "/", "dependencies": [ "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Hacl.HKDF.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HPKE.Interface.HKDF.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Hacl.HKDF", "short_module": "HK" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.HPKE.Interface", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE.Interface", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.HKDF.extract_st Spec.Hash.Definitions.SHA2_256
Prims.Tot
[ "total" ]
[]
[ "Hacl.HKDF.extract_sha2_256" ]
[]
false
false
false
true
false
let hkdf_extract256:HK.extract_st Hash.SHA2_256 =
Hacl.HKDF.extract_sha2_256
false
Steel.Semantics.Hoare.MST.fst
Steel.Semantics.Hoare.MST.depends_only_on_0_2
val depends_only_on_0_2 : interp: (_: hprop -> _: heap -> Prims.prop) -> disjoint: (_: heap -> _: heap -> Prims.prop) -> join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap) -> q: (_: heap -> _: a -> _: heap -> Prims.prop) -> fp_pre: hprop -> fp_post: (_: a -> hprop) -> Prims.logical
let depends_only_on_0_2 (#a:Type) (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint:heap -> heap -> prop) (join:(h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> a -> heap -> prop) (fp_pre:hprop) (fp_post:a -> hprop) = //can join any disjoint heap to the pre-heap and q is still valid (forall x (h_pre:fp_heap_0 interp fp_pre) h_post (h:heap{disjoint h_pre h}). q h_pre x h_post <==> q (join h_pre h) x h_post) /\ //can join any disjoint heap to the post-heap and q is still valid (forall x h_pre (h_post:fp_heap_0 interp (fp_post x)) (h:heap{disjoint h_post h}). q h_pre x h_post <==> q h_pre x (join h_post h))
{ "file_name": "lib/steel/Steel.Semantics.Hoare.MST.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 53, "end_line": 248, "start_col": 0, "start_line": 234 }
(* 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.Semantics.Hoare.MST module P = FStar.Preorder open FStar.Tactics open FStar.NMST (* * This module provides a semantic model for a combined effect of * divergence, state, and parallel composition of atomic actions. * * It is built over a monotonic state effect -- so that we can give * lock semantics using monotonicity * * It also builds a generic separation-logic-style program logic * for this effect, in a partial correctness setting. * It is also be possible to give a variant of this semantics for * total correctness. However, we specifically focus on partial correctness * here so that this semantics can be instantiated with lock operations, * which may deadlock. See ParTot.fst for a total-correctness variant of * these semantics. * * The program logic is specified in the Hoare-style pre- and postconditions *) /// Disabling projectors because we don't use them and they increase the typechecking time #push-options "--fuel 0 --ifuel 2 --z3rlimit 20 --print_implicits --print_universes \ --using_facts_from 'Prims FStar.Pervasives FStar.Preorder FStar.MST FStar.NMST Steel.Semantics.Hoare.MST'" (**** Begin state defn ****) /// We start by defining some basic notions for a commutative monoid. /// /// We could reuse FStar.Algebra.CommMonoid, but this style with /// quantifiers was more convenient for the proof done here. let symmetry #a (equals: a -> a -> prop) = forall x y. {:pattern (x `equals` y)} x `equals` y ==> y `equals` x let transitive #a (equals:a -> a -> prop) = forall x y z. x `equals` y /\ y `equals` z ==> x `equals` z let associative #a (equals: a -> a -> prop) (f: a -> a -> a)= forall x y z. f x (f y z) `equals` f (f x y) z let commutative #a (equals: a -> a -> prop) (f: a -> a -> a) = forall x y.{:pattern f x y} f x y `equals` f y x let is_unit #a (x:a) (equals: a -> a -> prop) (f:a -> a -> a) = forall y. {:pattern f x y \/ f y x} f x y `equals` y /\ f y x `equals` y let equals_ext #a (equals:a -> a -> prop) (f:a -> a -> a) = forall x1 x2 y. x1 `equals` x2 ==> f x1 y `equals` f x2 y let fp_heap_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (pre:hprop) = h:heap{interp pre h} let depends_only_on_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (q:heap -> prop) (fp: hprop) = forall (h0:fp_heap_0 interp fp) (h1:heap{disjoint h0 h1}). q h0 <==> q (join h0 h1) let fp_prop_0 (#heap:Type) (#hprop:Type) (interp:hprop -> heap -> prop) (disjoint: heap -> heap -> prop) (join: (h0:heap -> h1:heap{disjoint h0 h1} -> heap)) (fp:hprop) = p:(heap -> prop){p `(depends_only_on_0 interp disjoint join)` fp} noeq type st0 = { mem:Type u#2; core:mem -> mem; full_mem_pred: mem -> prop; locks_preorder:P.preorder (m:mem{full_mem_pred m}); hprop:Type u#2; locks_invariant: mem -> hprop; disjoint: mem -> mem -> prop; join: h0:mem -> h1:mem{disjoint h0 h1} -> mem; interp: hprop -> mem -> prop; emp:hprop; star: hprop -> hprop -> hprop; equals: hprop -> hprop -> prop; } /// disjointness is symmetric let disjoint_sym (st:st0) = forall h0 h1. st.disjoint h0 h1 <==> st.disjoint h1 h0 let disjoint_join (st:st0) = forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.disjoint m0 m1 /\ st.disjoint m0 m2 /\ st.disjoint (st.join m0 m1) m2 /\ st.disjoint (st.join m0 m2) m1 let join_commutative (st:st0 { disjoint_sym st }) = forall m0 m1. st.disjoint m0 m1 ==> st.join m0 m1 == st.join m1 m0 let join_associative (st:st0{disjoint_join st})= forall m0 m1 m2. st.disjoint m1 m2 /\ st.disjoint m0 (st.join m1 m2) ==> st.join m0 (st.join m1 m2) == st.join (st.join m0 m1) m2 //////////////////////////////////////////////////////////////////////////////// let interp_extensionality #r #s (equals:r -> r -> prop) (f:r -> s -> prop) = forall x y h. {:pattern equals x y; f x h} equals x y /\ f x h ==> f y h let affine (st:st0) = forall r0 r1 s. {:pattern (st.interp (r0 `st.star` r1) s) } st.interp (r0 `st.star` r1) s ==> st.interp r0 s //////////////////////////////////////////////////////////////////////////////// let depends_only_on (#st:st0) (q:st.mem -> prop) (fp: st.hprop) = depends_only_on_0 st.interp st.disjoint st.join q fp let fp_prop (#st:st0) (fp:st.hprop) = fp_prop_0 st.interp st.disjoint st.join fp let lemma_weaken_depends_only_on (#st:st0{affine st}) (fp0 fp1:st.hprop) (q:fp_prop fp0) : Lemma (q `depends_only_on` (fp0 `st.star` fp1)) = () let st_laws (st:st0) = (* standard laws about the equality relation *) symmetry st.equals /\ transitive st.equals /\ interp_extensionality st.equals st.interp /\ (* standard laws for star forming a CM *) associative st.equals st.star /\ commutative st.equals st.star /\ is_unit st.emp st.equals st.star /\ equals_ext st.equals st.star /\ (* We're working in an affine interpretation of SL *) affine st /\ (* laws about disjoint and join *) disjoint_sym st /\ disjoint_join st /\ join_commutative st /\ join_associative st let st = s:st0 { st_laws s } (**** End state defn ****) (**** Begin expects, provides, requires, and ensures defns ****) /// expects (the heap assertion expected by a computation) is simply an st.hprop /// /// provides, or the post heap assertion, is a st.hprop on [a]-typed result type post_t (st:st) (a:Type) = a -> st.hprop /// requires is a heap predicate that depends only on a pre heap assertion /// (where the notion of `depends only on` is defined above as part of the state definition) /// /// we call the type l_pre for logical precondition let l_pre (#st:st) (pre:st.hprop) = fp_prop pre /// ensures is a 2-state postcondition of type heap -> a -> heap -> prop /// /// To define ensures, we need a notion of depends_only_on_2 /// /// Essentially, in the first heap argument, postconditions depend only on the expects hprop /// and in the second heap argument, postconditions depend only on the provides hprop /// /// Also note that the support for depends_only_on_2 is not required from the underlying memory model
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.NMSTTotal.fst.checked", "FStar.NMST.fst.checked", "FStar.MST.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Steel.Semantics.Hoare.MST.fst" }
[ { "abbrev": false, "full_module": "FStar.NMST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "Steel.Semantics.Hoare", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_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
interp: (_: hprop -> _: heap -> Prims.prop) -> disjoint: (_: heap -> _: heap -> Prims.prop) -> join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap) -> q: (_: heap -> _: a -> _: heap -> Prims.prop) -> fp_pre: hprop -> fp_post: (_: a -> hprop) -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.l_and", "Prims.l_Forall", "Steel.Semantics.Hoare.MST.fp_heap_0", "Prims.l_iff", "Prims.logical" ]
[]
false
false
false
false
true
let depends_only_on_0_2 (#a #heap #hprop: Type) (interp: (hprop -> heap -> prop)) (disjoint: (heap -> heap -> prop)) (join: (h0: heap -> h1: heap{disjoint h0 h1} -> heap)) (q: (heap -> a -> heap -> prop)) (fp_pre: hprop) (fp_post: (a -> hprop)) =
(forall x (h_pre: fp_heap_0 interp fp_pre) h_post (h: heap{disjoint h_pre h}). q h_pre x h_post <==> q (join h_pre h) x h_post) /\ (forall x h_pre (h_post: fp_heap_0 interp (fp_post x)) (h: heap{disjoint h_post h}). q h_pre x h_post <==> q h_pre x (join h_post h))
false