effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val ___UINT64:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT64 : eqtype = U64.t | val ___UINT64:eqtype
let ___UINT64:eqtype = | false | null | false | U64.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt64.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32 | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT64:eqtype | [] | EverParse3d.Prelude.___UINT64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 30,
"end_line": 231,
"start_col": 25,
"start_line": 231
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let refine t (f:t -> bool) = x:t{f x} | let refine t (f: (t -> bool)) = | false | null | false | x: t{f x} | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"Prims.bool",
"Prims.b2t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val refine : t: Type -> f: (_: t -> Prims.bool) -> Type | [] | EverParse3d.Prelude.refine | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | t: Type -> f: (_: t -> Prims.bool) -> Type | {
"end_col": 37,
"end_line": 76,
"start_col": 29,
"start_line": 76
} |
|
Prims.Tot | val ___UINT32:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT32 : eqtype = U32.t | val ___UINT32:eqtype
let ___UINT32:eqtype = | false | null | false | U32.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt32.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16 | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT32:eqtype | [] | EverParse3d.Prelude.___UINT32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 30,
"end_line": 226,
"start_col": 25,
"start_line": 226
} |
Prims.Tot | val ___UINT8BE:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT8BE : eqtype = FStar.UInt8.t | val ___UINT8BE:eqtype
let ___UINT8BE:eqtype = | false | null | false | FStar.UInt8.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt8.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order") | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT8BE:eqtype | [] | EverParse3d.Prelude.___UINT8BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 39,
"end_line": 199,
"start_col": 26,
"start_line": 199
} |
Prims.Tot | val ___UINT64BE:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT64BE : eqtype = U64.t | val ___UINT64BE:eqtype
let ___UINT64BE:eqtype = | false | null | false | U64.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt64.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT64BE:eqtype | [] | EverParse3d.Prelude.___UINT64BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 32,
"end_line": 214,
"start_col": 27,
"start_line": 214
} |
Prims.Tot | val id (#t: Type) (x: t) : Tot t | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let id (#t: Type) (x: t) : Tot t = x | val id (#t: Type) (x: t) : Tot t
let id (#t: Type) (x: t) : Tot t = | false | null | false | x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val id (#t: Type) (x: t) : Tot t | [] | EverParse3d.Prelude.id | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: t -> t | {
"end_col": 36,
"end_line": 611,
"start_col": 35,
"start_line": 611
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___Bool = bool | let ___Bool = | false | null | false | bool | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"Prims.bool"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
//////////////////////////////////////////////////////////////////////////////// | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___Bool : Prims.eqtype | [] | EverParse3d.Prelude.___Bool | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 18,
"end_line": 189,
"start_col": 14,
"start_line": 189
} |
|
Prims.Tot | val ___UINT16BE:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT16BE : eqtype = U16.t | val ___UINT16BE:eqtype
let ___UINT16BE:eqtype = | false | null | false | U16.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt16.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT16BE:eqtype | [] | EverParse3d.Prelude.___UINT16BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 32,
"end_line": 204,
"start_col": 27,
"start_line": 204
} |
Prims.Tot | val ___UINT8:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT8 : eqtype = FStar.UInt8.t | val ___UINT8:eqtype
let ___UINT8:eqtype = | false | null | false | FStar.UInt8.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt8.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT8:eqtype | [] | EverParse3d.Prelude.___UINT8 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 37,
"end_line": 192,
"start_col": 24,
"start_line": 192
} |
Prims.Tot | val parse_unit:parser kind_unit unit | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parse_unit
: parser kind_unit unit
= parse_ret () | val parse_unit:parser kind_unit unit
let parse_unit:parser kind_unit unit = | false | null | false | parse_ret () | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"EverParse3d.Prelude.parse_ret",
"Prims.unit"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val parse_unit:parser kind_unit unit | [] | EverParse3d.Prelude.parse_unit | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind_unit Prims.unit | {
"end_col": 16,
"end_line": 237,
"start_col": 4,
"start_line": 237
} |
Prims.Tot | val ___UINT16:eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ___UINT16 : eqtype = U16.t | val ___UINT16:eqtype
let ___UINT16:eqtype = | false | null | false | U16.t | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt16.t"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian | false | true | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ___UINT16:eqtype | [] | EverParse3d.Prelude.___UINT16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.eqtype | {
"end_col": 30,
"end_line": 221,
"start_col": 25,
"start_line": 221
} |
Prims.Pure | val u32_logxor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y | val u32_logxor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z))
let u32_logxor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z)) = | false | null | false | UInt32.logxor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.logxor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt32.n",
"FStar.UInt.logxor",
"FStar.UInt32.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_logxor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z)) | [] | EverParse3d.Prelude.u32_logxor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 21,
"end_line": 484,
"start_col": 4,
"start_line": 484
} |
Prims.Pure | val u16_sub (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y | val u16_sub (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
let u16_sub (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = | false | null | false | UInt16.sub x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.sub",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Subtraction",
"FStar.UInt16.v",
"FStar.UInt16.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_sub (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) | [] | EverParse3d.Prelude.u16_sub | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 18,
"end_line": 359,
"start_col": 4,
"start_line": 359
} |
Prims.Pure | val u8_sub (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)
)
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y | val u8_sub (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)
)
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
let u8_sub (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)
)
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = | false | null | false | UInt8.sub x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.sub",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Subtraction",
"FStar.UInt8.v",
"FStar.UInt8.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_sub (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)
)
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) | [] | EverParse3d.Prelude.u8_sub | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 17,
"end_line": 273,
"start_col": 4,
"start_line": 273
} |
Prims.Pure | val u8_logor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y | val u8_logor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z))
let u8_logor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z)) = | false | null | false | UInt8.logor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.logor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt8.n",
"FStar.UInt.logor",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_logor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z)) | [] | EverParse3d.Prelude.u8_logor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 19,
"end_line": 319,
"start_col": 4,
"start_line": 319
} |
Prims.Pure | val u16_logxor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y | val u16_logxor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z))
let u16_logxor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z)) = | false | null | false | UInt16.logxor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.logxor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt16.n",
"FStar.UInt.logxor",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_logxor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z)) | [] | EverParse3d.Prelude.u16_logxor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 21,
"end_line": 397,
"start_col": 4,
"start_line": 397
} |
Prims.Pure | val u16_logor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y | val u16_logor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z))
let u16_logor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z)) = | false | null | false | UInt16.logor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.logor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt16.n",
"FStar.UInt.logor",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_logor (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z)) | [] | EverParse3d.Prelude.u16_logor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 20,
"end_line": 405,
"start_col": 4,
"start_line": 405
} |
Prims.Pure | val u32_mul (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r
"Cannot verify u32 multiplication"
(UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n))
(ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y | val u32_mul (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r
"Cannot verify u32 multiplication"
(UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n))
(ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y))
let u32_mul (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r
"Cannot verify u32 multiplication"
(UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n))
(ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) = | false | null | false | UInt32.mul x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.mul",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Multiply",
"FStar.UInt32.v",
"FStar.UInt32.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_mul (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r
"Cannot verify u32 multiplication"
(UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n))
(ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) | [] | EverParse3d.Prelude.u32_mul | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 18,
"end_line": 453,
"start_col": 4,
"start_line": 453
} |
Prims.Pure | val u8_logand (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y | val u8_logand (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z))
let u8_logand (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z)) = | false | null | false | UInt8.logand x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.logand",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt8.n",
"FStar.UInt.logand",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_logand (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z)) | [] | EverParse3d.Prelude.u8_logand | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 20,
"end_line": 303,
"start_col": 4,
"start_line": 303
} |
Prims.Tot | val uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x | val uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x})
let uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x}) = | false | null | false | FStar.Int.Cast.uint16_to_uint64 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt16.t",
"FStar.Int.Cast.uint16_to_uint64",
"FStar.UInt64.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt64.n",
"FStar.UInt16.n",
"FStar.UInt64.v",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint16_to_uint64 (x: U16.t) : (y: U64.t{U64.v y == U16.v x}) | [] | EverParse3d.Prelude.uint16_to_uint64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt16.t -> y: FStar.UInt64.t{FStar.UInt64.v y == FStar.UInt16.v x} | {
"end_col": 35,
"end_line": 633,
"start_col": 2,
"start_line": 633
} |
Prims.Tot | val uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x | val uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x})
let uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x}) = | false | null | false | FStar.Int.Cast.uint8_to_uint64 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt8.t",
"FStar.Int.Cast.uint8_to_uint64",
"FStar.UInt64.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt64.n",
"FStar.UInt8.n",
"FStar.UInt64.v",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint8_to_uint64 (x: U8.t) : (y: U64.t{U64.v y == U8.v x}) | [] | EverParse3d.Prelude.uint8_to_uint64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt8.t -> y: FStar.UInt64.t{FStar.UInt64.v y == FStar.UInt8.v x} | {
"end_col": 34,
"end_line": 625,
"start_col": 2,
"start_line": 625
} |
Prims.Pure | val u16_div (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y | val u16_div (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
let u16_div (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = | false | null | false | UInt16.div x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.div",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt16.v",
"Prims.op_Division"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_div (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) | [] | EverParse3d.Prelude.u16_div | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 18,
"end_line": 373,
"start_col": 4,
"start_line": 373
} |
Prims.Pure | val u16_lognot (r: range) (x: UInt16.t)
: Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x | val u16_lognot (r: range) (x: UInt16.t)
: Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
let u16_lognot (r: range) (x: UInt16.t)
: Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = | false | null | false | UInt16.lognot x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.lognot",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt16.n",
"FStar.UInt.lognot",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_lognot (r: range) (x: UInt16.t)
: Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) | [] | EverParse3d.Prelude.u16_lognot | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 19,
"end_line": 413,
"start_col": 4,
"start_line": 413
} |
Prims.Tot | val max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10) | val max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255)
let max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255) = | false | null | true | let open FStar.UInt in normalize_term_spec (max_int 10) | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term_spec",
"Prims.int",
"FStar.UInt.max_int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255) | [] | EverParse3d.Prelude.max_int_sizes | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Prims.squash (FStar.UInt.max_int 10 == 1023 /\ FStar.UInt.max_int 8 == 255) | {
"end_col": 36,
"end_line": 253,
"start_col": 4,
"start_line": 253
} |
FStar.Pervasives.Lemma | val pow2_values (x: nat)
: Lemma
(let p = pow2 x in
match x with
| 0 -> p = 1
| 1 -> p = 2
| 2 -> p = 4
| 3 -> p = 8
| 4 -> p = 16
| 5 -> p = 32
| 6 -> p = 64
| 7 -> p = 128
| 8 -> p = 256
| _ -> True) [SMTPat (pow2 x)] | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8) | val pow2_values (x: nat)
: Lemma
(let p = pow2 x in
match x with
| 0 -> p = 1
| 1 -> p = 2
| 2 -> p = 4
| 3 -> p = 8
| 4 -> p = 16
| 5 -> p = 32
| 6 -> p = 64
| 7 -> p = 128
| 8 -> p = 256
| _ -> True) [SMTPat (pow2 x)]
let pow2_values (x: nat)
: Lemma
(let p = pow2 x in
match x with
| 0 -> p = 1
| 1 -> p = 2
| 2 -> p = 4
| 3 -> p = 8
| 4 -> p = 16
| 5 -> p = 32
| 6 -> p = 64
| 7 -> p = 128
| 8 -> p = 256
| _ -> True) [SMTPat (pow2 x)] = | false | null | true | norm_spec [delta; zeta; primops] (pow2 0);
norm_spec [delta; zeta; primops] (pow2 1);
norm_spec [delta; zeta; primops] (pow2 2);
norm_spec [delta; zeta; primops] (pow2 3);
norm_spec [delta; zeta; primops] (pow2 4);
norm_spec [delta; zeta; primops] (pow2 5);
norm_spec [delta; zeta; primops] (pow2 6);
norm_spec [delta; zeta; primops] (pow2 7);
norm_spec [delta; zeta; primops] (pow2 8) | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"lemma"
] | [
"Prims.nat",
"FStar.Pervasives.norm_spec",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"Prims.Nil",
"Prims.pos",
"Prims.pow2",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow2_values (x: nat)
: Lemma
(let p = pow2 x in
match x with
| 0 -> p = 1
| 1 -> p = 2
| 2 -> p = 4
| 3 -> p = 8
| 4 -> p = 16
| 5 -> p = 32
| 6 -> p = 64
| 7 -> p = 128
| 8 -> p = 256
| _ -> True) [SMTPat (pow2 x)] | [] | EverParse3d.Prelude.pow2_values | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(let p = Prims.pow2 x in
(match x with
| 0 -> p = 1
| 1 -> p = 2
| 2 -> p = 4
| 3 -> p = 8
| 4 -> p = 16
| 5 -> p = 32
| 6 -> p = 64
| 7 -> p = 128
| 8 -> p = 256
| _ -> Prims.l_True)
<:
Type0)) [SMTPat (Prims.pow2 x)] | {
"end_col": 43,
"end_line": 48,
"start_col": 4,
"start_line": 40
} |
Prims.Tot | val uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x | val uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x})
let uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x}) = | false | null | false | FStar.Int.Cast.uint32_to_uint64 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"FStar.Int.Cast.uint32_to_uint64",
"FStar.UInt64.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt64.n",
"FStar.UInt32.n",
"FStar.UInt64.v",
"FStar.UInt32.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint32_to_uint64 (x: U32.t) : (y: U64.t{U64.v y == U32.v x}) | [] | EverParse3d.Prelude.uint32_to_uint64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt32.t -> y: FStar.UInt64.t{FStar.UInt64.v y == FStar.UInt32.v x} | {
"end_col": 35,
"end_line": 637,
"start_col": 2,
"start_line": 637
} |
Prims.Tot | val uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x | val uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x})
let uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x}) = | false | null | false | FStar.Int.Cast.uint16_to_uint32 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt16.t",
"FStar.Int.Cast.uint16_to_uint32",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt16.n",
"FStar.UInt32.v",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint16_to_uint32 (x: U16.t) : (y: U32.t{U32.v y == U16.v x}) | [] | EverParse3d.Prelude.uint16_to_uint32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt16.t -> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt16.v x} | {
"end_col": 35,
"end_line": 629,
"start_col": 2,
"start_line": 629
} |
Prims.Pure | val u64_lognot (r: range) (x: UInt64.t)
: Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x | val u64_lognot (r: range) (x: UInt64.t)
: Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
let u64_lognot (r: range) (x: UInt64.t)
: Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = | false | null | false | UInt64.lognot x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.lognot",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"FStar.UInt.lognot",
"FStar.UInt64.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_lognot (r: range) (x: UInt64.t)
: Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) | [] | EverParse3d.Prelude.u64_lognot | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 19,
"end_line": 586,
"start_col": 4,
"start_line": 586
} |
Prims.Pure | val u32_sub (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y | val u32_sub (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
let u32_sub (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = | false | null | false | UInt32.sub x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.sub",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Subtraction",
"FStar.UInt32.v",
"FStar.UInt32.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_sub (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) | [] | EverParse3d.Prelude.u32_sub | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 18,
"end_line": 446,
"start_col": 4,
"start_line": 446
} |
Prims.Pure | val u16_mul (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r
"Cannot verify u16 multiplication"
(UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n))
(ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y | val u16_mul (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r
"Cannot verify u16 multiplication"
(UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n))
(ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y))
let u16_mul (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r
"Cannot verify u16 multiplication"
(UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n))
(ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) = | false | null | false | UInt16.mul x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.mul",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Multiply",
"FStar.UInt16.v",
"FStar.UInt16.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_mul (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r
"Cannot verify u16 multiplication"
(UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n))
(ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) | [] | EverParse3d.Prelude.u16_mul | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 18,
"end_line": 366,
"start_col": 4,
"start_line": 366
} |
Prims.Pure | val u32_add (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y | val u32_add (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
let u32_add (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = | false | null | false | UInt32.add x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.add",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Addition",
"FStar.UInt32.v",
"FStar.UInt32.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_add (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires
labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) | [] | EverParse3d.Prelude.u32_add | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 18,
"end_line": 439,
"start_col": 4,
"start_line": 439
} |
Prims.Pure | val u64_mul (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r
"Cannot verify u64 multiplication"
(UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n))
(ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y | val u64_mul (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r
"Cannot verify u64 multiplication"
(UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n))
(ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y))
let u64_mul (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r
"Cannot verify u64 multiplication"
(UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n))
(ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) = | false | null | false | UInt64.mul x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.mul",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Multiply",
"FStar.UInt64.v",
"FStar.UInt64.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_mul (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r
"Cannot verify u64 multiplication"
(UInt.size ((UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) UInt64.n))
(ensures fun z -> UInt64.v z == (UInt64.v x) `Prims.op_Multiply` (UInt64.v y)) | [] | EverParse3d.Prelude.u64_mul | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 18,
"end_line": 539,
"start_col": 4,
"start_line": 539
} |
Prims.Pure | val u32_logor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y | val u32_logor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z))
let u32_logor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z)) = | false | null | false | UInt32.logor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.logor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt32.n",
"FStar.UInt.logor",
"FStar.UInt32.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_logor (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z)) | [] | EverParse3d.Prelude.u32_logor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 20,
"end_line": 492,
"start_col": 4,
"start_line": 492
} |
Prims.Pure | val u64_logxor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y | val u64_logxor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z))
let u64_logxor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z)) = | false | null | false | UInt64.logxor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.logxor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"FStar.UInt.logxor",
"FStar.UInt64.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_logxor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logxor` (UInt64.v y) == UInt64.v z)) | [] | EverParse3d.Prelude.u64_logxor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 21,
"end_line": 570,
"start_col": 4,
"start_line": 570
} |
Prims.Pure | val u8_logxor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y | val u8_logxor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z))
let u8_logxor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z)) = | false | null | false | UInt8.logxor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.logxor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt8.n",
"FStar.UInt.logxor",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_logxor (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z)) | [] | EverParse3d.Prelude.u8_logxor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 20,
"end_line": 311,
"start_col": 4,
"start_line": 311
} |
Prims.Tot | val uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x | val uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x})
let uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x}) = | false | null | false | FStar.Int.Cast.uint8_to_uint32 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt8.t",
"FStar.Int.Cast.uint8_to_uint32",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt8.n",
"FStar.UInt32.v",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint8_to_uint32 (x: U8.t) : (y: U32.t{U32.v y == U8.v x}) | [] | EverParse3d.Prelude.uint8_to_uint32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt8.t -> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt8.v x} | {
"end_col": 34,
"end_line": 621,
"start_col": 2,
"start_line": 621
} |
Prims.Pure | val u64_logor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y | val u64_logor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z))
let u64_logor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z)) = | false | null | false | UInt64.logor x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.logor",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"FStar.UInt.logor",
"FStar.UInt64.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_logor (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logor` (UInt64.v y) == UInt64.v z)) | [] | EverParse3d.Prelude.u64_logor | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 20,
"end_line": 578,
"start_col": 4,
"start_line": 578
} |
Prims.Pure | val u8_div (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y | val u8_div (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
let u8_div (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = | false | null | false | UInt8.div x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.div",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Division"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_div (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) | [] | EverParse3d.Prelude.u8_div | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 17,
"end_line": 287,
"start_col": 4,
"start_line": 287
} |
Prims.Pure | val u64_logand (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y | val u64_logand (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z))
let u64_logand (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z)) = | false | null | false | UInt64.logand x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.logand",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"FStar.UInt.logand",
"FStar.UInt64.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_logand (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> (UInt64.v x) `UInt.logand` (UInt64.v y) == UInt64.v z)) | [] | EverParse3d.Prelude.u64_logand | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 21,
"end_line": 562,
"start_col": 4,
"start_line": 562
} |
Prims.Pure | val u64_add (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y | val u64_add (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
let u64_add (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = | false | null | false | UInt64.add x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.add",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Addition",
"FStar.UInt64.v",
"FStar.UInt64.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_add (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) | [] | EverParse3d.Prelude.u64_add | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 18,
"end_line": 525,
"start_col": 4,
"start_line": 525
} |
Prims.Pure | val u8_lognot (r: range) (x: UInt8.t)
: Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x | val u8_lognot (r: range) (x: UInt8.t)
: Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
let u8_lognot (r: range) (x: UInt8.t)
: Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = | false | null | false | UInt8.lognot x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.lognot",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt8.n",
"FStar.UInt.lognot",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_lognot (r: range) (x: UInt8.t)
: Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) | [] | EverParse3d.Prelude.u8_lognot | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 18,
"end_line": 327,
"start_col": 4,
"start_line": 327
} |
Prims.Tot | val uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint16 x | val uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x})
let uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x}) = | false | null | false | FStar.Int.Cast.uint64_to_uint16 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"Prims.b2t",
"FStar.UInt.fits",
"FStar.UInt64.v",
"FStar.Int.Cast.uint64_to_uint16",
"FStar.UInt16.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt16.n",
"FStar.UInt64.n",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
inline_for_extraction noextract
let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint64_to_uint16 (x: U64.t{FStar.UInt.fits (U64.v x) 16}) : (y: U16.t{U16.v y == U64.v x}) | [] | EverParse3d.Prelude.uint64_to_uint16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt64.t{FStar.UInt.fits (FStar.UInt64.v x) 16}
-> y: FStar.UInt16.t{FStar.UInt16.v y == FStar.UInt64.v x} | {
"end_col": 35,
"end_line": 659,
"start_col": 2,
"start_line": 659
} |
FStar.Pervasives.Lemma | val cast_mul_fits_16_32 (x y: U16.t)
: Lemma
(FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))
32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))] | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cast_mul_fits_16_32 (x y :U16.t)
: Lemma (
FStar.UInt.fits
((U32.v (C.uint16_to_uint32 x))
`op_Multiply`
(U32.v (C.uint16_to_uint32 y)))
32)
[SMTPat ((U32.v (C.uint16_to_uint32 x))
`op_Multiply`
(U32.v (C.uint16_to_uint32 y)))]
= let n = U32.v (C.uint16_to_uint32 x) in
let m = U32.v (C.uint16_to_uint32 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 16) | val cast_mul_fits_16_32 (x y: U16.t)
: Lemma
(FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))
32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))]
let cast_mul_fits_16_32 (x y: U16.t)
: Lemma
(FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))
32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))] = | false | null | true | let n = U32.v (C.uint16_to_uint32 x) in
let m = U32.v (C.uint16_to_uint32 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 16) | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"lemma"
] | [
"FStar.UInt16.t",
"FStar.Math.Lemmas.lemma_mult_lt_sqr",
"Prims.pow2",
"FStar.UInt.uint_t",
"FStar.UInt32.v",
"FStar.Int.Cast.uint16_to_uint32",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"FStar.UInt.fits",
"Prims.op_Multiply",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.int",
"Prims.Nil"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
inline_for_extraction noextract
let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x
inline_for_extraction noextract
let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint16 x
inline_for_extraction noextract
let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint8 x
(*** Lemma for casts ***)
let cast_mul_fits_8_16 (x y :U8.t)
: Lemma (
FStar.UInt.fits
((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))
16)
[SMTPat ((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))]
= let n = U16.v (C.uint8_to_uint16 x) in
let m = U16.v (C.uint8_to_uint16 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8)
let cast_mul_fits_16_32 (x y :U16.t)
: Lemma (
FStar.UInt.fits
((U32.v (C.uint16_to_uint32 x))
`op_Multiply`
(U32.v (C.uint16_to_uint32 y)))
32)
[SMTPat ((U32.v (C.uint16_to_uint32 x))
`op_Multiply` | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cast_mul_fits_16_32 (x y: U16.t)
: Lemma
(FStar.UInt.fits ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))
32) [SMTPat ((U32.v (C.uint16_to_uint32 x)) `op_Multiply` (U32.v (C.uint16_to_uint32 y)))] | [] | EverParse3d.Prelude.cast_mul_fits_16_32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt16.t -> y: FStar.UInt16.t
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt.fits (FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 x) *
FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 y))
32)
[
SMTPat (FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 x) *
FStar.UInt32.v (FStar.Int.Cast.uint16_to_uint32 y))
] | {
"end_col": 53,
"end_line": 693,
"start_col": 3,
"start_line": 691
} |
FStar.Pervasives.Lemma | val cast_mul_fits_8_16 (x y: U8.t)
: Lemma
(FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))
16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cast_mul_fits_8_16 (x y :U8.t)
: Lemma (
FStar.UInt.fits
((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))
16)
[SMTPat ((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))]
= let n = U16.v (C.uint8_to_uint16 x) in
let m = U16.v (C.uint8_to_uint16 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8) | val cast_mul_fits_8_16 (x y: U8.t)
: Lemma
(FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))
16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))]
let cast_mul_fits_8_16 (x y: U8.t)
: Lemma
(FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))
16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] = | false | null | true | let n = U16.v (C.uint8_to_uint16 x) in
let m = U16.v (C.uint8_to_uint16 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8) | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"lemma"
] | [
"FStar.UInt8.t",
"FStar.Math.Lemmas.lemma_mult_lt_sqr",
"Prims.pow2",
"FStar.UInt.uint_t",
"FStar.UInt16.v",
"FStar.Int.Cast.uint8_to_uint16",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"FStar.UInt.fits",
"Prims.op_Multiply",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.int",
"Prims.Nil"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
inline_for_extraction noextract
let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x
inline_for_extraction noextract
let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint16 x
inline_for_extraction noextract
let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint8 x
(*** Lemma for casts ***)
let cast_mul_fits_8_16 (x y :U8.t)
: Lemma (
FStar.UInt.fits
((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))
16)
[SMTPat ((U16.v (C.uint8_to_uint16 x))
`op_Multiply` | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cast_mul_fits_8_16 (x y: U8.t)
: Lemma
(FStar.UInt.fits ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))
16) [SMTPat ((U16.v (C.uint8_to_uint16 x)) `op_Multiply` (U16.v (C.uint8_to_uint16 y)))] | [] | EverParse3d.Prelude.cast_mul_fits_8_16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt8.t -> y: FStar.UInt8.t
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt.fits (FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 x) *
FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 y))
16)
[
SMTPat (FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 x) *
FStar.UInt16.v (FStar.Int.Cast.uint8_to_uint16 y))
] | {
"end_col": 52,
"end_line": 679,
"start_col": 3,
"start_line": 677
} |
Prims.Pure | val u32_shift_left (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s | val u32_shift_left (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
let u32_shift_left (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = | false | null | false | UInt32.shift_left a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.shift_left",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt32.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_left"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_shift_left (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) | [] | EverParse3d.Prelude.u32_shift_left | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 25,
"end_line": 516,
"start_col": 4,
"start_line": 516
} |
Prims.Pure | val u64_rem (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y | val u64_rem (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
let u64_rem (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = | false | null | false | UInt64.rem x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.rem",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt64.v",
"FStar.UInt.uint_t",
"FStar.UInt64.n",
"FStar.UInt.mod"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_rem (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) | [] | EverParse3d.Prelude.u64_rem | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 18,
"end_line": 554,
"start_col": 4,
"start_line": 554
} |
Prims.Pure | val u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s | val u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
let u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = | false | null | false | UInt16.shift_right a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt32.t",
"FStar.UInt16.shift_right",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt16.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_right",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) | [] | EverParse3d.Prelude.u16_shift_right | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt16.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 26,
"end_line": 421,
"start_col": 4,
"start_line": 421
} |
Prims.Pure | val u32_rem (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y | val u32_rem (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
let u32_rem (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = | false | null | false | UInt32.rem x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.rem",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt32.v",
"FStar.UInt.uint_t",
"FStar.UInt32.n",
"FStar.UInt.mod"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_rem (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) | [] | EverParse3d.Prelude.u32_rem | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 18,
"end_line": 468,
"start_col": 4,
"start_line": 468
} |
Prims.Tot | val uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x | val uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x})
let uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x}) = | false | null | false | FStar.Int.Cast.uint32_to_uint8 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.b2t",
"FStar.UInt.fits",
"FStar.UInt32.v",
"FStar.Int.Cast.uint32_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt32.n",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint32_to_uint8 (x: U32.t{FStar.UInt.fits (U32.v x) 8}) : (y: U8.t{U8.v y == U32.v x}) | [] | EverParse3d.Prelude.uint32_to_uint8 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt32.t{FStar.UInt.fits (FStar.UInt32.v x) 8}
-> y: FStar.UInt8.t{FStar.UInt8.v y == FStar.UInt32.v x} | {
"end_col": 34,
"end_line": 651,
"start_col": 2,
"start_line": 651
} |
Prims.Pure | val u32_lognot (r: range) (x: UInt32.t)
: Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x | val u32_lognot (r: range) (x: UInt32.t)
: Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
let u32_lognot (r: range) (x: UInt32.t)
: Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = | false | null | false | UInt32.lognot x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.lognot",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt32.n",
"FStar.UInt.lognot",
"FStar.UInt32.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_lognot (r: range) (x: UInt32.t)
: Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) | [] | EverParse3d.Prelude.u32_lognot | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 19,
"end_line": 500,
"start_col": 4,
"start_line": 500
} |
Prims.Tot | val uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x | val uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x})
let uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x}) = | false | null | false | FStar.Int.Cast.uint64_to_uint32 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"Prims.b2t",
"FStar.UInt.fits",
"FStar.UInt64.v",
"FStar.Int.Cast.uint64_to_uint32",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt64.n",
"FStar.UInt32.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint64_to_uint32 (x: U64.t{FStar.UInt.fits (U64.v x) 32}) : (y: U32.t{U32.v y == U64.v x}) | [] | EverParse3d.Prelude.uint64_to_uint32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt64.t{FStar.UInt.fits (FStar.UInt64.v x) 32}
-> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt64.v x} | {
"end_col": 35,
"end_line": 655,
"start_col": 2,
"start_line": 655
} |
Prims.Pure | val u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s | val u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
let u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = | false | null | false | UInt16.shift_left a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt32.t",
"FStar.UInt16.shift_left",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt16.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_left",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) | [] | EverParse3d.Prelude.u16_shift_left | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt16.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 25,
"end_line": 429,
"start_col": 4,
"start_line": 429
} |
Prims.Tot | val uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x | val uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x})
let uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x}) = | false | null | false | FStar.Int.Cast.uint16_to_uint8 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt16.t",
"Prims.b2t",
"FStar.UInt.fits",
"FStar.UInt16.v",
"FStar.Int.Cast.uint16_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt16.n",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint16_to_uint8 (x: U16.t{FStar.UInt.fits (U16.v x) 8}) : (y: U8.t{U8.v y == U16.v x}) | [] | EverParse3d.Prelude.uint16_to_uint8 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt16.t{FStar.UInt.fits (FStar.UInt16.v x) 8}
-> y: FStar.UInt8.t{FStar.UInt8.v y == FStar.UInt16.v x} | {
"end_col": 34,
"end_line": 643,
"start_col": 2,
"start_line": 643
} |
Prims.Pure | val u8_add (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y | val u8_add (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
let u8_add (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = | false | null | false | UInt8.add x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.add",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Addition",
"FStar.UInt8.v",
"FStar.UInt8.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_add (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) | [] | EverParse3d.Prelude.u8_add | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 17,
"end_line": 266,
"start_col": 4,
"start_line": 266
} |
Prims.Pure | val u8_mul (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires
labeled r
"Cannot verify u8 multiplication"
(UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n))
(ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y | val u8_mul (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires
labeled r
"Cannot verify u8 multiplication"
(UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n))
(ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y))
let u8_mul (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires
labeled r
"Cannot verify u8 multiplication"
(UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n))
(ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) = | false | null | false | UInt8.mul x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.mul",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Multiply",
"FStar.UInt8.v",
"FStar.UInt8.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_mul (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires
labeled r
"Cannot verify u8 multiplication"
(UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n))
(ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) | [] | EverParse3d.Prelude.u8_mul | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 17,
"end_line": 280,
"start_col": 4,
"start_line": 280
} |
Prims.Pure | val u8_rem (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y | val u8_rem (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
let u8_rem (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = | false | null | false | UInt8.rem x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt8.rem",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt8.v",
"FStar.UInt.uint_t",
"FStar.UInt8.n",
"FStar.UInt.mod"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_rem (r: range) (x y: UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) | [] | EverParse3d.Prelude.u8_rem | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 17,
"end_line": 295,
"start_col": 4,
"start_line": 295
} |
Prims.Pure | val u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s | val u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
let u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = | false | null | false | UInt8.shift_right a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt32.t",
"FStar.UInt8.shift_right",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt8.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_right",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) | [] | EverParse3d.Prelude.u8_shift_right | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 25,
"end_line": 335,
"start_col": 4,
"start_line": 335
} |
Prims.Pure | val u16_add (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y | val u16_add (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
let u16_add (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = | false | null | false | UInt16.add x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.add",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Addition",
"FStar.UInt16.v",
"FStar.UInt16.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_add (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires
labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) | [] | EverParse3d.Prelude.u16_add | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 18,
"end_line": 352,
"start_col": 4,
"start_line": 352
} |
Prims.Pure | val u16_logand (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y | val u16_logand (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z))
let u16_logand (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z)) = | false | null | false | UInt16.logand x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.logand",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt16.n",
"FStar.UInt.logand",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_logand (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z)) | [] | EverParse3d.Prelude.u16_logand | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 21,
"end_line": 389,
"start_col": 4,
"start_line": 389
} |
Prims.Pure | val u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s | val u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
let u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = | false | null | false | UInt8.shift_left a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt8.t",
"FStar.UInt32.t",
"FStar.UInt8.shift_left",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt8.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_left",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) | [] | EverParse3d.Prelude.u8_shift_left | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t | {
"end_col": 24,
"end_line": 343,
"start_col": 4,
"start_line": 343
} |
Prims.Pure | val u16_rem (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y | val u16_rem (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
let u16_rem (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = | false | null | false | UInt16.rem x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt16.t",
"FStar.UInt16.rem",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt16.v",
"FStar.UInt.uint_t",
"FStar.UInt16.n",
"FStar.UInt.mod"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u16_rem (r: range) (x y: UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) | [] | EverParse3d.Prelude.u16_rem | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t | {
"end_col": 18,
"end_line": 381,
"start_col": 4,
"start_line": 381
} |
Prims.Pure | val u32_logand (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y | val u32_logand (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z))
let u32_logand (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z)) = | false | null | false | UInt32.logand x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.logand",
"Prims.l_True",
"Prims.eq2",
"FStar.UInt.uint_t",
"FStar.UInt32.n",
"FStar.UInt.logand",
"FStar.UInt32.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_logand (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z)) | [] | EverParse3d.Prelude.u32_logand | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 21,
"end_line": 476,
"start_col": 4,
"start_line": 476
} |
Prims.Pure | val u64_sub (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y | val u64_sub (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
let u64_sub (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = | false | null | false | UInt64.sub x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.sub",
"FStar.Range.labeled",
"FStar.UInt.size",
"Prims.op_Subtraction",
"FStar.UInt64.v",
"FStar.UInt64.n",
"Prims.eq2",
"Prims.int"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_sub (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires
labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) | [] | EverParse3d.Prelude.u64_sub | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 18,
"end_line": 532,
"start_col": 4,
"start_line": 532
} |
Prims.Tot | val uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x | val uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x})
let uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x}) = | false | null | false | FStar.Int.Cast.uint8_to_uint16 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt8.t",
"FStar.Int.Cast.uint8_to_uint16",
"FStar.UInt16.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt16.n",
"FStar.UInt8.n",
"FStar.UInt16.v",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint8_to_uint16 (x: U8.t) : (y: U16.t{U16.v y == U8.v x}) | [] | EverParse3d.Prelude.uint8_to_uint16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt8.t -> y: FStar.UInt16.t{FStar.UInt16.v y == FStar.UInt8.v x} | {
"end_col": 34,
"end_line": 617,
"start_col": 2,
"start_line": 617
} |
Prims.Pure | val u32_div (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y | val u32_div (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
let u32_div (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = | false | null | false | UInt32.div x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.div",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt32.v",
"Prims.op_Division"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_div (r: range) (x y: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) | [] | EverParse3d.Prelude.u32_div | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 18,
"end_line": 460,
"start_col": 4,
"start_line": 460
} |
Prims.Tot | val uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x | val uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x})
let uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x}) = | false | null | false | FStar.Int.Cast.uint32_to_uint16 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.b2t",
"FStar.UInt.fits",
"FStar.UInt32.v",
"FStar.Int.Cast.uint32_to_uint16",
"FStar.UInt16.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt16.n",
"FStar.UInt32.n",
"FStar.UInt16.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint32_to_uint16 (x: U32.t{FStar.UInt.fits (U32.v x) 16}) : (y: U16.t{U16.v y == U32.v x}) | [] | EverParse3d.Prelude.uint32_to_uint16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt32.t{FStar.UInt.fits (FStar.UInt32.v x) 16}
-> y: FStar.UInt16.t{FStar.UInt16.v y == FStar.UInt32.v x} | {
"end_col": 35,
"end_line": 647,
"start_col": 2,
"start_line": 647
} |
Prims.Pure | val u32_shift_right (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s | val u32_shift_right (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
let u32_shift_right (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = | false | null | false | UInt32.shift_right a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt32.t",
"FStar.UInt32.shift_right",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt32.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_right"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u32_shift_right (r: range) (a s: UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) | [] | EverParse3d.Prelude.u32_shift_right | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 26,
"end_line": 508,
"start_col": 4,
"start_line": 508
} |
Prims.Pure | val u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s | val u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
let u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = | false | null | false | UInt64.shift_left a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt32.t",
"FStar.UInt64.shift_left",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt64.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_left",
"FStar.UInt64.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_shift_left (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) | [] | EverParse3d.Prelude.u64_shift_left | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 25,
"end_line": 602,
"start_col": 4,
"start_line": 602
} |
Prims.Pure | val u64_div (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y | val u64_div (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
let u64_div (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = | false | null | false | UInt64.div x y | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt64.div",
"FStar.Range.labeled",
"Prims.l_not",
"Prims.eq2",
"Prims.int",
"FStar.UInt64.v",
"Prims.op_Division"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_div (r: range) (x y: UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) | [] | EverParse3d.Prelude.u64_div | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 18,
"end_line": 546,
"start_col": 4,
"start_line": 546
} |
Prims.Pure | val u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s | val u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
let u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = | false | null | false | UInt64.shift_right a s | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [] | [
"FStar.Range.range",
"FStar.UInt64.t",
"FStar.UInt32.t",
"FStar.UInt64.shift_right",
"FStar.Range.labeled",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"FStar.UInt64.n",
"Prims.op_Equality",
"FStar.UInt.uint_t",
"FStar.UInt.shift_right",
"FStar.UInt64.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val u64_shift_right (r: range) (a: UInt64.t) (s: UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) | [] | EverParse3d.Prelude.u64_shift_right | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | r: FStar.Range.range -> a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t | {
"end_col": 26,
"end_line": 594,
"start_col": 4,
"start_line": 594
} |
Prims.Tot | val uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x}) | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint8 x | val uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x})
let uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x}) = | false | null | false | FStar.Int.Cast.uint64_to_uint8 x | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"total"
] | [
"FStar.UInt64.t",
"Prims.b2t",
"FStar.UInt.fits",
"FStar.UInt64.v",
"FStar.Int.Cast.uint64_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt64.n",
"FStar.UInt8.v"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
inline_for_extraction noextract
let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x
inline_for_extraction noextract
let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint16 x
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint64_to_uint8 (x: U64.t{FStar.UInt.fits (U64.v x) 8}) : (y: U8.t{U8.v y == U64.v x}) | [] | EverParse3d.Prelude.uint64_to_uint8 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt64.t{FStar.UInt.fits (FStar.UInt64.v x) 8}
-> y: FStar.UInt8.t{FStar.UInt8.v y == FStar.UInt64.v x} | {
"end_col": 34,
"end_line": 663,
"start_col": 2,
"start_line": 663
} |
FStar.Pervasives.Lemma | val cast_mul_fits_32_64 (x y: U32.t)
: Lemma
(FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))
64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))] | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "C"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "FStar.Range",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Kinds",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d.Prelude.StaticHeader",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverParse3d",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let cast_mul_fits_32_64 (x y :U32.t)
: Lemma (
FStar.UInt.fits
((U64.v (C.uint32_to_uint64 x))
`op_Multiply`
(U64.v (C.uint32_to_uint64 y)))
64)
[SMTPat ((U64.v (C.uint32_to_uint64 x))
`op_Multiply`
(U64.v (C.uint32_to_uint64 y)))]
= let n = U64.v (C.uint32_to_uint64 x) in
let m = U64.v (C.uint32_to_uint64 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 32) | val cast_mul_fits_32_64 (x y: U32.t)
: Lemma
(FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))
64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))]
let cast_mul_fits_32_64 (x y: U32.t)
: Lemma
(FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))
64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))] = | false | null | true | let n = U64.v (C.uint32_to_uint64 x) in
let m = U64.v (C.uint32_to_uint64 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 32) | {
"checked_file": "EverParse3d.Prelude.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"EverParse3d.Prelude.StaticHeader.fst.checked",
"EverParse3d.Kinds.fsti.checked"
],
"interface_file": false,
"source_file": "EverParse3d.Prelude.fsti"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"FStar.Math.Lemmas.lemma_mult_lt_sqr",
"Prims.pow2",
"FStar.UInt.uint_t",
"FStar.UInt64.v",
"FStar.Int.Cast.uint32_to_uint64",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"FStar.UInt.fits",
"Prims.op_Multiply",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.int",
"Prims.Nil"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
include EverParse3d.Prelude.StaticHeader
include EverParse3d.Kinds
open FStar.Range
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module C = FStar.Int.Cast
let pow2_values (x:nat) : Lemma
(let p = pow2 x in
match x with
| 0 -> p=1
| 1 -> p=2
| 2 -> p=4
| 3 -> p=8
| 4 -> p=16
| 5 -> p=32
| 6 -> p=64
| 7 -> p=128
| 8 -> p=256
| _ -> True)
[SMTPat (pow2 x)]
= norm_spec [delta;zeta;primops] (pow2 0);
norm_spec [delta;zeta;primops] (pow2 1);
norm_spec [delta;zeta;primops] (pow2 2);
norm_spec [delta;zeta;primops] (pow2 3);
norm_spec [delta;zeta;primops] (pow2 4);
norm_spec [delta;zeta;primops] (pow2 5);
norm_spec [delta;zeta;primops] (pow2 6);
norm_spec [delta;zeta;primops] (pow2 7);
norm_spec [delta;zeta;primops] (pow2 8)
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
[@@erasable]
inline_for_extraction
noextract
val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
inline_for_extraction noextract
val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x))
: Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) )
/// Parser: sequencing
inline_for_extraction noextract
val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1)
(#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2)
: Tot (parser (and_then_kind k1 k2) (t1 * t2))
/// Parser: filter
let refine t (f:t -> bool) = x:t{f x}
inline_for_extraction noextract
val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f))
inline_for_extraction noextract
val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k' k) t)
inline_for_extraction noextract
val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
(#nz':_) (#wk': _) (k':parser_kind nz' wk')
: Tot (parser (glb k k') t)
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
val parse_impos (_:unit)
: parser impos_kind False
let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type)
: Type
= if e then a() else b()
val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk)
(e:bool)
(#a:squash e -> Type)
(#b:squash (not e) -> Type)
(p1:squash e -> parser k (a()))
(p2:squash (not e) -> parser k (b()))
: Tot (parser k (t_ite e a b))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized list whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val nlist (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
/////
// Parse all of the remaining bytes of the input buffer
/////
noextract
val all_bytes: Type0
val parse_all_bytes: parser kind_all_bytes all_bytes
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is at most n
////////////////////////////////////////////////////////////////////////////////
val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_at_most (t_at_most n t))
////////////////////////////////////////////////////////////////////////////////
// Variable-sized element whose size in bytes is exactly n
////////////////////////////////////////////////////////////////////////////////
val t_exact (n:U32.t) (t:Type u#r) : Type u#r
inline_for_extraction noextract
val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t)
: Tot (parser kind_t_exact (t_exact n t))
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
inline_for_extraction noextract
val read_filter (#nz:_)
(#k: parser_kind nz WeakKindStrongPrefix)
(#t: Type)
(#p: parser k t)
(p32: reader p)
(f: (t -> bool))
: reader (parse_filter p f)
inline_for_extraction noextract
val read_impos : reader (parse_impos())
/// Parse a zero-terminated string
noextract
val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
noextract
val all_zeros: Type0
val parse_all_zeros: parser kind_all_zeros all_zeros
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction
let ___Bool = bool
/// UINT8
let ___UINT8 : eqtype = FStar.UInt8.t
val parse____UINT8 : parser kind____UINT8 ___UINT8
val read____UINT8 : reader parse____UINT8
// Big-endian (or "network order")
/// UINT8BE
let ___UINT8BE : eqtype = FStar.UInt8.t
val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
val read____UINT8BE : reader parse____UINT8BE
/// UInt16BE
let ___UINT16BE : eqtype = U16.t
val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
val read____UINT16BE : reader parse____UINT16BE
/// UInt32BE
let ___UINT32BE : eqtype = U32.t
val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
val read____UINT32BE : reader parse____UINT32BE
/// UInt64BE
let ___UINT64BE : eqtype = U64.t
val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
val read____UINT64BE : reader parse____UINT64BE
// Little-endian
/// UInt16
let ___UINT16 : eqtype = U16.t
val parse____UINT16 : parser kind____UINT16 ___UINT16
val read____UINT16 : reader parse____UINT16
/// UInt32
let ___UINT32 : eqtype = U32.t
val parse____UINT32 : parser kind____UINT32 ___UINT32
val read____UINT32 : reader parse____UINT32
/// UInt64
let ___UINT64 : eqtype = U64.t
val parse____UINT64 : parser kind____UINT64 ___UINT64
val read____UINT64 : reader parse____UINT64
let parse_unit
: parser kind_unit unit
= parse_ret ()
inline_for_extraction noextract
val read_unit
: reader (parse_ret ())
////////////////////////////////////////////////////////////////////////////////
//Convenience lemmas for bounded arithmetic, especially on bitfields
////////////////////////////////////////////////////////////////////////////////
let max_int_sizes
: squash FStar.UInt.(
max_int 10 == 1023 /\
max_int 8 == 255
)
= let open FStar.UInt in
normalize_term_spec (max_int 10)
(*
* AR: scaffolding for getting arithmetic error locations in the 3d file
*)
(*** UInt8 operations ***)
unfold noextract
let u8_add (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
= UInt8.add x y
unfold noextract
let u8_sub (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
= UInt8.sub x y
unfold noextract
let u8_mul (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n))
(ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y)
= UInt8.mul x y
unfold noextract
let u8_div (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0))
(ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
= UInt8.div x y
(** Euclidean remainder *)
unfold noextract
let u8_rem (r:range) (x y:UInt8.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
= UInt8.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z))
= UInt8.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z))
= UInt8.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z))
= UInt8.logor x y
(** Bitwise logical negation *)
unfold noextract
let u8_lognot (r:range) (x:UInt8.t)
: Pure UInt8.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
= UInt8.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t)
: Pure UInt8.t
(requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
= UInt8.shift_left a s
(*** UInt16 operations ***)
unfold noextract
let u16_add (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
= UInt16.add x y
unfold noextract
let u16_sub (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
= UInt16.sub x y
unfold noextract
let u16_mul (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n))
(ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y)
= UInt16.mul x y
unfold noextract
let u16_div (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0))
(ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
= UInt16.div x y
(** Euclidean remainder *)
unfold noextract
let u16_rem (r:range) (x y:UInt16.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
= UInt16.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z))
= UInt16.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z))
= UInt16.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z))
= UInt16.logor x y
(** Bitwise logical negation *)
unfold noextract
let u16_lognot (r:range) (x:UInt16.t)
: Pure UInt16.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
= UInt16.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t)
: Pure UInt16.t
(requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
= UInt16.shift_left a s
(*** UInt32 operations ***)
unfold noextract
let u32_add (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
= UInt32.add x y
unfold noextract
let u32_sub (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
= UInt32.sub x y
unfold noextract
let u32_mul (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n))
(ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y)
= UInt32.mul x y
unfold noextract
let u32_div (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0))
(ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
= UInt32.div x y
(** Euclidean remainder *)
unfold noextract
let u32_rem (r:range) (x y:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
= UInt32.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z))
= UInt32.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z))
= UInt32.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z))
= UInt32.logor x y
(** Bitwise logical negation *)
unfold noextract
let u32_lognot (r:range) (x:UInt32.t)
: Pure UInt32.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
= UInt32.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t)
: Pure UInt32.t
(requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
= UInt32.shift_left a s
(*** UInt64 operators ***)
unfold noextract
let u64_add (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y)
= UInt64.add x y
unfold noextract
let u64_sub (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
= UInt64.sub x y
unfold noextract
let u64_mul (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n))
(ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y)
= UInt64.mul x y
unfold noextract
let u64_div (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0))
(ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y)
= UInt64.div x y
(** Euclidean remainder *)
unfold noextract
let u64_rem (r:range) (x y:UInt64.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0))
(ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z))
= UInt64.rem x y
(** Bitwise logical conjunction *)
unfold noextract
let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z))
= UInt64.logand x y
(** Bitwise logical exclusive-or *)
unfold noextract
let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z))
= UInt64.logxor x y
(** Bitwise logical disjunction *)
unfold noextract
let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z))
= UInt64.logor x y
(** Bitwise logical negation *)
unfold noextract
let u64_lognot (r:range) (x:UInt64.t)
: Pure UInt64.t
(requires True)
(ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z))
= UInt64.lognot x
(** Shift right with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_right a s
(** Shift left with zero fill, shifting at most the integer width *)
unfold noextract
let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t)
: Pure UInt64.t
(requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n))
(ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c))
= UInt64.shift_left a s
(*** Casts ***)
(* Identity function for endianness-only casts *)
inline_for_extraction noextract
let id (#t: Type) (x: t) : Tot t = x
(** Widening casts **)
inline_for_extraction noextract
let uint8_to_uint16 (x:U8.t) : (y:U16.t{U16.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint16 x
inline_for_extraction noextract
let uint8_to_uint32 (x:U8.t) : (y:U32.t{U32.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint32 x
inline_for_extraction noextract
let uint8_to_uint64 (x:U8.t) : (y:U64.t{U64.v y == U8.v x}) =
FStar.Int.Cast.uint8_to_uint64 x
inline_for_extraction noextract
let uint16_to_uint32 (x:U16.t) : (y:U32.t{U32.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint32 x
inline_for_extraction noextract
let uint16_to_uint64 (x:U16.t) : (y:U64.t{U64.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint64 x
inline_for_extraction noextract
let uint32_to_uint64 (x:U32.t) : (y:U64.t{U64.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint64 x
(** Narrowing casts, only when narrowing does not lose any precision **)
inline_for_extraction noextract
let uint16_to_uint8 (x:U16.t{FStar.UInt.fits (U16.v x) 8}) : (y:U8.t{U8.v y == U16.v x}) =
FStar.Int.Cast.uint16_to_uint8 x
inline_for_extraction noextract
let uint32_to_uint16 (x:U32.t{FStar.UInt.fits (U32.v x) 16}) : (y:U16.t{U16.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint16 x
inline_for_extraction noextract
let uint32_to_uint8 (x:U32.t{FStar.UInt.fits (U32.v x) 8}) : (y:U8.t{U8.v y == U32.v x}) =
FStar.Int.Cast.uint32_to_uint8 x
inline_for_extraction noextract
let uint64_to_uint32 (x:U64.t{FStar.UInt.fits (U64.v x) 32}) : (y:U32.t{U32.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint32 x
inline_for_extraction noextract
let uint64_to_uint16 (x:U64.t{FStar.UInt.fits (U64.v x) 16}) : (y:U16.t{U16.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint16 x
inline_for_extraction noextract
let uint64_to_uint8 (x:U64.t{FStar.UInt.fits (U64.v x) 8}) : (y:U8.t{U8.v y == U64.v x}) =
FStar.Int.Cast.uint64_to_uint8 x
(*** Lemma for casts ***)
let cast_mul_fits_8_16 (x y :U8.t)
: Lemma (
FStar.UInt.fits
((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))
16)
[SMTPat ((U16.v (C.uint8_to_uint16 x))
`op_Multiply`
(U16.v (C.uint8_to_uint16 y)))]
= let n = U16.v (C.uint8_to_uint16 x) in
let m = U16.v (C.uint8_to_uint16 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 8)
let cast_mul_fits_16_32 (x y :U16.t)
: Lemma (
FStar.UInt.fits
((U32.v (C.uint16_to_uint32 x))
`op_Multiply`
(U32.v (C.uint16_to_uint32 y)))
32)
[SMTPat ((U32.v (C.uint16_to_uint32 x))
`op_Multiply`
(U32.v (C.uint16_to_uint32 y)))]
= let n = U32.v (C.uint16_to_uint32 x) in
let m = U32.v (C.uint16_to_uint32 y) in
FStar.Math.Lemmas.lemma_mult_lt_sqr n m (pow2 16)
let cast_mul_fits_32_64 (x y :U32.t)
: Lemma (
FStar.UInt.fits
((U64.v (C.uint32_to_uint64 x))
`op_Multiply`
(U64.v (C.uint32_to_uint64 y)))
64)
[SMTPat ((U64.v (C.uint32_to_uint64 x))
`op_Multiply` | false | false | EverParse3d.Prelude.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": [
"smt.qi.eager_threshold=10"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cast_mul_fits_32_64 (x y: U32.t)
: Lemma
(FStar.UInt.fits ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))
64) [SMTPat ((U64.v (C.uint32_to_uint64 x)) `op_Multiply` (U64.v (C.uint32_to_uint64 y)))] | [] | EverParse3d.Prelude.cast_mul_fits_32_64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt32.t -> y: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt.fits (FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 x) *
FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 y))
64)
[
SMTPat (FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 x) *
FStar.UInt64.v (FStar.Int.Cast.uint32_to_uint64 y))
] | {
"end_col": 53,
"end_line": 707,
"start_col": 3,
"start_line": 705
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) | let qelem_wide5 = | false | null | false | (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple10",
"Lib.IntTypes.uint64"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem_wide5 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.qelem_wide5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 107,
"end_line": 11,
"start_col": 18,
"start_line": 11
} |
|
Prims.Tot | val pow112:(pow112: pos{pow112 == pow2 112}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) | val pow112:(pow112: pos{pow112 == pow2 112})
let pow112:(pow112: pos{pow112 == pow2 112}) = | false | null | false | normalize_term (pow2 112) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56 | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow112:(pow112: pos{pow112 == pow2 112}) | [] | Hacl.Spec.BignumQ.Definitions.pow112 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow112: Prims.pos{pow112 == Prims.pow2 112} | {
"end_col": 73,
"end_line": 23,
"start_col": 48,
"start_line": 23
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64) | let qelem5 = | false | null | false | (uint64 & uint64 & uint64 & uint64 & uint64) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.uint64"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem5 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.qelem5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 57,
"end_line": 10,
"start_col": 13,
"start_line": 10
} |
|
Prims.Tot | val pow168:(pow168: pos{pow168 == pow2 168}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) | val pow168:(pow168: pos{pow168 == pow2 168})
let pow168:(pow168: pos{pow168 == pow2 168}) = | false | null | false | normalize_term (pow2 168) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56 | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow168:(pow168: pos{pow168 == pow2 168}) | [] | Hacl.Spec.BignumQ.Definitions.pow168 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow168: Prims.pos{pow168 == Prims.pow2 168} | {
"end_col": 73,
"end_line": 24,
"start_col": 48,
"start_line": 24
} |
Prims.Tot | val pow224:(pow224: pos{pow224 == pow2 224}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) | val pow224:(pow224: pos{pow224 == pow2 224})
let pow224:(pow224: pos{pow224 == pow2 224}) = | false | null | false | normalize_term (pow2 224) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow224:(pow224: pos{pow224 == pow2 224}) | [] | Hacl.Spec.BignumQ.Definitions.pow224 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow224: Prims.pos{pow224 == Prims.pow2 224} | {
"end_col": 73,
"end_line": 25,
"start_col": 48,
"start_line": 25
} |
Prims.Tot | val pow280:(pow280: pos{pow280 == pow2 280}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) | val pow280:(pow280: pos{pow280 == pow2 280})
let pow280:(pow280: pos{pow280 == pow2 280}) = | false | null | false | normalize_term (pow2 280) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow280:(pow280: pos{pow280 == pow2 280}) | [] | Hacl.Spec.BignumQ.Definitions.pow280 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow280: Prims.pos{pow280 == Prims.pow2 280} | {
"end_col": 73,
"end_line": 26,
"start_col": 48,
"start_line": 26
} |
Prims.Tot | val pow336:(pow336: pos{pow336 == pow2 336}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) | val pow336:(pow336: pos{pow336 == pow2 336})
let pow336:(pow336: pos{pow336 == pow2 336}) = | false | null | false | normalize_term (pow2 336) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow336:(pow336: pos{pow336 == pow2 336}) | [] | Hacl.Spec.BignumQ.Definitions.pow336 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow336: Prims.pos{pow336 == Prims.pow2 336} | {
"end_col": 73,
"end_line": 27,
"start_col": 48,
"start_line": 27
} |
Prims.Tot | val pow392:(pow392: pos{pow392 == pow2 392}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) | val pow392:(pow392: pos{pow392 == pow2 392})
let pow392:(pow392: pos{pow392 == pow2 392}) = | false | null | false | normalize_term (pow2 392) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow392:(pow392: pos{pow392 == pow2 392}) | [] | Hacl.Spec.BignumQ.Definitions.pow392 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow392: Prims.pos{pow392 == Prims.pow2 392} | {
"end_col": 73,
"end_line": 28,
"start_col": 48,
"start_line": 28
} |
Prims.Tot | val pow448:(pow448: pos{pow448 == pow2 448}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448) | val pow448:(pow448: pos{pow448 == pow2 448})
let pow448:(pow448: pos{pow448 == pow2 448}) = | false | null | false | normalize_term (pow2 448) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow448:(pow448: pos{pow448 == pow2 448}) | [] | Hacl.Spec.BignumQ.Definitions.pow448 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow448: Prims.pos{pow448 == Prims.pow2 448} | {
"end_col": 73,
"end_line": 29,
"start_col": 48,
"start_line": 29
} |
Prims.Tot | val pow504:(pow504: pos{pow504 == pow2 504}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) | val pow504:(pow504: pos{pow504 == pow2 504})
let pow504:(pow504: pos{pow504 == pow2 504}) = | false | null | false | normalize_term (pow2 504) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.normalize_term",
"Prims.pos",
"Prims.eq2",
"Prims.pow2"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow504:(pow504: pos{pow504 == pow2 504}) | [] | Hacl.Spec.BignumQ.Definitions.pow504 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow504: Prims.pos{pow504 == Prims.pow2 504} | {
"end_col": 73,
"end_line": 30,
"start_col": 48,
"start_line": 30
} |
Prims.Tot | val pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56 | val pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56})
let pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) = | false | null | false | let pow56:pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == (65536 * pow56) * pow56);
pow56 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.pow2",
"FStar.Mul.op_Star",
"Prims.pos",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Pervasives.normalize_term"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64) | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pow56:(pow56: pos{pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) | [] | Hacl.Spec.BignumQ.Definitions.pow56 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | pow56: Prims.pos{Prims.pow2 64 == 256 * pow56 /\ pow56 == Prims.pow2 56} | {
"end_col": 7,
"end_line": 20,
"start_col": 69,
"start_line": 14
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} | let scale64_5 = | false | null | false | x:
nat5
{ let x1, x2, x3, x4, x5 = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 } | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Hacl.Spec.BignumQ.Definitions.nat5",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val scale64_5 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.scale64_5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 71,
"end_line": 38,
"start_col": 16,
"start_line": 37
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scale64 = s:nat{s <= 256} | let scale64 = | false | null | false | s: nat{s <= 256} | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val scale64 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.scale64 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 29,
"end_line": 33,
"start_col": 14,
"start_line": 33
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let max56 = pow56 - 1 | let max56 = | false | null | false | pow56 - 1 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Prims.op_Subtraction",
"Hacl.Spec.BignumQ.Definitions.pow56"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val max56 : Prims.int | [] | Hacl.Spec.BignumQ.Definitions.max56 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.int | {
"end_col": 21,
"end_line": 46,
"start_col": 12,
"start_line": 46
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256} | let scale64_10 = | false | null | false | x:
nat10
{ let x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\ x6 <= 256 /\ x7 <= 256 /\
x8 <= 256 /\ x9 <= 256 /\ x10 <= 256 } | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Hacl.Spec.BignumQ.Definitions.nat10",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256} | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val scale64_10 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.scale64_10 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 86,
"end_line": 42,
"start_col": 17,
"start_line": 40
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem_fits1 (x:uint64) (m:scale64) =
uint_v x <= m * max56 | let qelem_fits1 (x: uint64) (m: scale64) = | false | null | false | uint_v x <= m * max56 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint64",
"Hacl.Spec.BignumQ.Definitions.scale64",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.uint_v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Hacl.Spec.BignumQ.Definitions.max56",
"Prims.bool"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
inline_for_extraction noextract
let max56 = pow56 - 1 | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem_fits1 : x: Lib.IntTypes.uint64 -> m: Hacl.Spec.BignumQ.Definitions.scale64 -> Prims.bool | [] | Hacl.Spec.BignumQ.Definitions.qelem_fits1 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Lib.IntTypes.uint64 -> m: Hacl.Spec.BignumQ.Definitions.scale64 -> Prims.bool | {
"end_col": 23,
"end_line": 49,
"start_col": 2,
"start_line": 49
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat5 = (nat & nat & nat & nat & nat) | let nat5 = | false | null | false | (nat & nat & nat & nat & nat) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple5",
"Prims.nat"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504) | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat5 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.nat5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 40,
"end_line": 34,
"start_col": 11,
"start_line": 34
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) | let nat10 = | false | null | false | (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat) | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple10",
"Prims.nat"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256} | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nat10 : Type0 | [] | Hacl.Spec.BignumQ.Definitions.nat10 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 71,
"end_line": 35,
"start_col": 12,
"start_line": 35
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem_fits5 (f:qelem5) (m:scale64_5) =
let (x1,x2,x3,x4,x5) = f in
let (m1,m2,m3,m4,m5) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 | let qelem_fits5 (f: qelem5) (m: scale64_5) = | false | null | false | let x1, x2, x3, x4, x5 = f in
let m1, m2, m3, m4, m5 = m in
qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Hacl.Spec.BignumQ.Definitions.qelem5",
"Hacl.Spec.BignumQ.Definitions.scale64_5",
"Lib.IntTypes.uint64",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Hacl.Spec.BignumQ.Definitions.qelem_fits1",
"Prims.logical"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
inline_for_extraction noextract
let max56 = pow56 - 1
let qelem_fits1 (x:uint64) (m:scale64) =
uint_v x <= m * max56 | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem_fits5 : f: Hacl.Spec.BignumQ.Definitions.qelem5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_5
-> Prims.logical | [] | Hacl.Spec.BignumQ.Definitions.qelem_fits5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.BignumQ.Definitions.qelem5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_5
-> Prims.logical | {
"end_col": 19,
"end_line": 59,
"start_col": 42,
"start_line": 52
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem_wide_fits5 (f:qelem_wide5) (m:scale64_10) =
let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = f in
let (m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 /\
qelem_fits1 x6 m6 /\
qelem_fits1 x7 m7 /\
qelem_fits1 x8 m8 /\
qelem_fits1 x9 m9 /\
qelem_fits1 x10 m10 | let qelem_wide_fits5 (f: qelem_wide5) (m: scale64_10) = | false | null | false | let x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 = f in
let m1, m2, m3, m4, m5, m6, m7, m8, m9, m10 = m in
qelem_fits1 x1 m1 /\ qelem_fits1 x2 m2 /\ qelem_fits1 x3 m3 /\ qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 /\ qelem_fits1 x6 m6 /\ qelem_fits1 x7 m7 /\ qelem_fits1 x8 m8 /\
qelem_fits1 x9 m9 /\ qelem_fits1 x10 m10 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"total"
] | [
"Hacl.Spec.BignumQ.Definitions.qelem_wide5",
"Hacl.Spec.BignumQ.Definitions.scale64_10",
"Lib.IntTypes.uint64",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Hacl.Spec.BignumQ.Definitions.qelem_fits1",
"Prims.logical"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
inline_for_extraction noextract
let max56 = pow56 - 1
let qelem_fits1 (x:uint64) (m:scale64) =
uint_v x <= m * max56
let qelem_fits5 (f:qelem5) (m:scale64_5) =
let (x1,x2,x3,x4,x5) = f in
let (m1,m2,m3,m4,m5) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 | false | true | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem_wide_fits5 : f: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_10
-> Prims.logical | [] | Hacl.Spec.BignumQ.Definitions.qelem_wide_fits5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> m: Hacl.Spec.BignumQ.Definitions.scale64_10
-> Prims.logical | {
"end_col": 21,
"end_line": 74,
"start_col": 53,
"start_line": 62
} |
|
Prims.GTot | val as_nat5: f:qelem5 -> GTot nat | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_nat5 f =
let (s0, s1, s2, s3, s4) = f in
v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 | val as_nat5: f:qelem5 -> GTot nat
let as_nat5 f = | false | null | false | let s0, s1, s2, s3, s4 = f in
v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"sometrivial"
] | [
"Hacl.Spec.BignumQ.Definitions.qelem5",
"Lib.IntTypes.uint64",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Hacl.Spec.BignumQ.Definitions.pow56",
"Hacl.Spec.BignumQ.Definitions.pow112",
"Hacl.Spec.BignumQ.Definitions.pow168",
"Hacl.Spec.BignumQ.Definitions.pow224",
"Prims.nat"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
inline_for_extraction noextract
let max56 = pow56 - 1
let qelem_fits1 (x:uint64) (m:scale64) =
uint_v x <= m * max56
let qelem_fits5 (f:qelem5) (m:scale64_5) =
let (x1,x2,x3,x4,x5) = f in
let (m1,m2,m3,m4,m5) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5
let qelem_wide_fits5 (f:qelem_wide5) (m:scale64_10) =
let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = f in
let (m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 /\
qelem_fits1 x6 m6 /\
qelem_fits1 x7 m7 /\
qelem_fits1 x8 m8 /\
qelem_fits1 x9 m9 /\
qelem_fits1 x10 m10
noextract | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_nat5: f:qelem5 -> GTot nat | [] | Hacl.Spec.BignumQ.Definitions.as_nat5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.BignumQ.Definitions.qelem5 -> Prims.GTot Prims.nat | {
"end_col": 69,
"end_line": 81,
"start_col": 15,
"start_line": 79
} |
Prims.GTot | val wide_as_nat5: f:qelem_wide5 -> GTot nat | [
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.BignumQ",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let wide_as_nat5 f =
let (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) = f in
v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 +
v s5 * pow280 + v s6 * pow336 + v s7 * pow392 + v s8 * pow448 + v s9 * pow504 | val wide_as_nat5: f:qelem_wide5 -> GTot nat
let wide_as_nat5 f = | false | null | false | let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 = f in
v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224 + v s5 * pow280 + v s6 * pow336 +
v s7 * pow392 +
v s8 * pow448 +
v s9 * pow504 | {
"checked_file": "Hacl.Spec.BignumQ.Definitions.fst.checked",
"dependencies": [
"Spec.Ed25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.BignumQ.Definitions.fst"
} | [
"sometrivial"
] | [
"Hacl.Spec.BignumQ.Definitions.qelem_wide5",
"Lib.IntTypes.uint64",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Hacl.Spec.BignumQ.Definitions.pow56",
"Hacl.Spec.BignumQ.Definitions.pow112",
"Hacl.Spec.BignumQ.Definitions.pow168",
"Hacl.Spec.BignumQ.Definitions.pow224",
"Hacl.Spec.BignumQ.Definitions.pow280",
"Hacl.Spec.BignumQ.Definitions.pow336",
"Hacl.Spec.BignumQ.Definitions.pow392",
"Hacl.Spec.BignumQ.Definitions.pow448",
"Hacl.Spec.BignumQ.Definitions.pow504",
"Prims.nat"
] | [] | module Hacl.Spec.BignumQ.Definitions
open FStar.Mul
open Lib.IntTypes
module S = Spec.Ed25519
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let qelem5 = (uint64 & uint64 & uint64 & uint64 & uint64)
let qelem_wide5 = (uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64 & uint64)
//abstract
let pow56: (pow56:pos {pow2 64 == 256 * pow56 /\ pow56 == pow2 56}) =
let pow56: pos = normalize_term (pow2 56) in
assert_norm (pow56 > 0);
assert_norm (pow56 == pow2 56);
assert_norm (pow2 64 == 256 * pow56);
assert_norm (pow2 128 == 65536 * pow56 * pow56);
pow56
let pow112: (pow112:pos {pow112 == pow2 112}) = normalize_term (pow2 112)
let pow168: (pow168:pos {pow168 == pow2 168}) = normalize_term (pow2 168)
let pow224: (pow224:pos {pow224 == pow2 224}) = normalize_term (pow2 224)
let pow280: (pow280:pos {pow280 == pow2 280}) = normalize_term (pow2 280)
let pow336: (pow336:pos {pow336 == pow2 336}) = normalize_term (pow2 336)
let pow392: (pow392:pos {pow392 == pow2 392}) = normalize_term (pow2 392)
let pow448: (pow448:pos {pow448 == pow2 448}) = normalize_term (pow2 448)
let pow504: (pow504:pos {pow504 == pow2 504}) = normalize_term (pow2 504)
let scale64 = s:nat{s <= 256}
let nat5 = (nat & nat & nat & nat & nat)
let nat10 = (nat & nat & nat & nat & nat & nat & nat & nat & nat & nat)
let scale64_5 = x:nat5{let (x1,x2,x3,x4,x5) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256}
let scale64_10 = x:nat10{let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = x in
x1 <= 256 /\ x2 <= 256 /\ x3 <= 256 /\ x4 <= 256 /\ x5 <= 256 /\
x6 <= 256 /\ x7 <= 256 /\ x8 <= 256 /\ x9 <= 256 /\ x10 <= 256}
inline_for_extraction noextract
let max56 = pow56 - 1
let qelem_fits1 (x:uint64) (m:scale64) =
uint_v x <= m * max56
let qelem_fits5 (f:qelem5) (m:scale64_5) =
let (x1,x2,x3,x4,x5) = f in
let (m1,m2,m3,m4,m5) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5
let qelem_wide_fits5 (f:qelem_wide5) (m:scale64_10) =
let (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) = f in
let (m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) = m in
qelem_fits1 x1 m1 /\
qelem_fits1 x2 m2 /\
qelem_fits1 x3 m3 /\
qelem_fits1 x4 m4 /\
qelem_fits1 x5 m5 /\
qelem_fits1 x6 m6 /\
qelem_fits1 x7 m7 /\
qelem_fits1 x8 m8 /\
qelem_fits1 x9 m9 /\
qelem_fits1 x10 m10
noextract
val as_nat5: f:qelem5 -> GTot nat
let as_nat5 f =
let (s0, s1, s2, s3, s4) = f in
v s0 + v s1 * pow56 + v s2 * pow112 + v s3 * pow168 + v s4 * pow224
noextract | false | false | Hacl.Spec.BignumQ.Definitions.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val wide_as_nat5: f:qelem_wide5 -> GTot nat | [] | Hacl.Spec.BignumQ.Definitions.wide_as_nat5 | {
"file_name": "code/ed25519/Hacl.Spec.BignumQ.Definitions.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> Prims.GTot Prims.nat | {
"end_col": 79,
"end_line": 89,
"start_col": 20,
"start_line": 86
} |
Prims.Tot | val bn_sqr_u64:bn_sqr_st U64 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Squaring",
"short_module": "SS"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Multiplication",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sqr_u64 : bn_sqr_st U64 = bn_sqr | val bn_sqr_u64:bn_sqr_st U64
let bn_sqr_u64:bn_sqr_st U64 = | false | null | false | bn_sqr | {
"checked_file": "Hacl.Bignum.Multiplication.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Squaring.fst.checked",
"Hacl.Spec.Bignum.Multiplication.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Multiplication.fst"
} | [
"total"
] | [
"Hacl.Bignum.Multiplication.bn_sqr",
"Lib.IntTypes.U64"
] | [] | module Hacl.Bignum.Multiplication
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Multiplication
module SS = Hacl.Spec.Bignum.Squaring
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_f (as_seq h a) l in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let h1 = ST.get () in
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i;
lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_lshift_add:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b_j:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in
let h0 = ST.get () in
update_sub_f_carry h0 res j aLen
(fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j))
(fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
inline_for_extraction noextract
let bn_mul_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul: #t:limb_t -> bn_mul_st t
let bn_mul #t aLen a bLen b res =
[@inline_let]
let resLen = aLen +! bLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@ inline_let]
let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in
loop1 h0 bLen res spec
(fun j ->
Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j);
let bj = b.(j) in
res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res
)
[@CInline]
let bn_mul_u32 : bn_mul_st U32 = bn_mul
[@CInline]
let bn_mul_u64 : bn_mul_st U64 = bn_mul
inline_for_extraction noextract
let bn_mul_u (#t:limb_t) : bn_mul_st t =
match t with
| U32 -> bn_mul_u32
| U64 -> bn_mul_u64
inline_for_extraction noextract
val bn_sqr_diag:
#t:limb_t
-> aLen:size_t{v aLen + v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a /\
as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a))
let bn_sqr_diag #t aLen a res =
let h0 = ST.get () in
[@inline_let]
let spec h = SS.bn_sqr_diag_f (as_seq h a) in
loop1 h0 aLen res spec
(fun i ->
Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i);
let (hi, lo) = mul_wide a.(i) a.(i) in
res.(2ul *! i) <- lo;
res.(2ul *! i +! 1ul) <- hi)
// This code is taken from BoringSSL
// https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) =
aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == SS.bn_sqr (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr: #t:limb_t -> bn_sqr_st t
let bn_sqr #t aLen a res =
push_frame ();
[@inline_let]
let resLen = aLen +! aLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@inline_let]
let spec h = SS.bn_sqr_f (as_seq h a) in
loop1 h0 aLen res spec
(fun j ->
Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j);
let ab = sub a 0ul j in
let a_j = a.(j) in
res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res
);
let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in
LowStar.Ignore.ignore c0;
let tmp = create resLen (uint #t 0) in
bn_sqr_diag aLen a tmp;
let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in
LowStar.Ignore.ignore c1;
pop_frame ()
[@CInline]
let bn_sqr_u32 : bn_sqr_st U32 = bn_sqr | false | true | Hacl.Bignum.Multiplication.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sqr_u64:bn_sqr_st U64 | [] | Hacl.Bignum.Multiplication.bn_sqr_u64 | {
"file_name": "code/bignum/Hacl.Bignum.Multiplication.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Multiplication.bn_sqr_st Lib.IntTypes.U64 | {
"end_col": 39,
"end_line": 239,
"start_col": 33,
"start_line": 239
} |
Prims.Tot | val bn_mul_u32:bn_mul_st U32 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Squaring",
"short_module": "SS"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Multiplication",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mul_u32 : bn_mul_st U32 = bn_mul | val bn_mul_u32:bn_mul_st U32
let bn_mul_u32:bn_mul_st U32 = | false | null | false | bn_mul | {
"checked_file": "Hacl.Bignum.Multiplication.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Squaring.fst.checked",
"Hacl.Spec.Bignum.Multiplication.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Multiplication.fst"
} | [
"total"
] | [
"Hacl.Bignum.Multiplication.bn_mul",
"Lib.IntTypes.U32"
] | [] | module Hacl.Bignum.Multiplication
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Multiplication
module SS = Hacl.Spec.Bignum.Squaring
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_f (as_seq h a) l in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let h1 = ST.get () in
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i;
lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_lshift_add:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b_j:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in
let h0 = ST.get () in
update_sub_f_carry h0 res j aLen
(fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j))
(fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
inline_for_extraction noextract
let bn_mul_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul: #t:limb_t -> bn_mul_st t
let bn_mul #t aLen a bLen b res =
[@inline_let]
let resLen = aLen +! bLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@ inline_let]
let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in
loop1 h0 bLen res spec
(fun j ->
Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j);
let bj = b.(j) in
res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res
) | false | true | Hacl.Bignum.Multiplication.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mul_u32:bn_mul_st U32 | [] | Hacl.Bignum.Multiplication.bn_mul_u32 | {
"file_name": "code/bignum/Hacl.Bignum.Multiplication.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Multiplication.bn_mul_st Lib.IntTypes.U32 | {
"end_col": 39,
"end_line": 157,
"start_col": 33,
"start_line": 157
} |
Prims.Tot | val bn_mul_u64:bn_mul_st U64 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Squaring",
"short_module": "SS"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Multiplication",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mul_u64 : bn_mul_st U64 = bn_mul | val bn_mul_u64:bn_mul_st U64
let bn_mul_u64:bn_mul_st U64 = | false | null | false | bn_mul | {
"checked_file": "Hacl.Bignum.Multiplication.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Squaring.fst.checked",
"Hacl.Spec.Bignum.Multiplication.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Multiplication.fst"
} | [
"total"
] | [
"Hacl.Bignum.Multiplication.bn_mul",
"Lib.IntTypes.U64"
] | [] | module Hacl.Bignum.Multiplication
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Multiplication
module SS = Hacl.Spec.Bignum.Squaring
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_f (as_seq h a) l in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let h1 = ST.get () in
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i;
lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_lshift_add:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b_j:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in
let h0 = ST.get () in
update_sub_f_carry h0 res j aLen
(fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j))
(fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
inline_for_extraction noextract
let bn_mul_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul: #t:limb_t -> bn_mul_st t
let bn_mul #t aLen a bLen b res =
[@inline_let]
let resLen = aLen +! bLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@ inline_let]
let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in
loop1 h0 bLen res spec
(fun j ->
Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j);
let bj = b.(j) in
res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res
)
[@CInline]
let bn_mul_u32 : bn_mul_st U32 = bn_mul | false | true | Hacl.Bignum.Multiplication.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mul_u64:bn_mul_st U64 | [] | Hacl.Bignum.Multiplication.bn_mul_u64 | {
"file_name": "code/bignum/Hacl.Bignum.Multiplication.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Multiplication.bn_mul_st Lib.IntTypes.U64 | {
"end_col": 39,
"end_line": 159,
"start_col": 33,
"start_line": 159
} |
Prims.Tot | val bn_sqr_u32:bn_sqr_st U32 | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Squaring",
"short_module": "SS"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Multiplication",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sqr_u32 : bn_sqr_st U32 = bn_sqr | val bn_sqr_u32:bn_sqr_st U32
let bn_sqr_u32:bn_sqr_st U32 = | false | null | false | bn_sqr | {
"checked_file": "Hacl.Bignum.Multiplication.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Squaring.fst.checked",
"Hacl.Spec.Bignum.Multiplication.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Multiplication.fst"
} | [
"total"
] | [
"Hacl.Bignum.Multiplication.bn_sqr",
"Lib.IntTypes.U32"
] | [] | module Hacl.Bignum.Multiplication
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Multiplication
module SS = Hacl.Spec.Bignum.Squaring
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_f (as_seq h a) l in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let h1 = ST.get () in
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i;
lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_lshift_add:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b_j:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in
let h0 = ST.get () in
update_sub_f_carry h0 res j aLen
(fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j))
(fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
inline_for_extraction noextract
let bn_mul_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul: #t:limb_t -> bn_mul_st t
let bn_mul #t aLen a bLen b res =
[@inline_let]
let resLen = aLen +! bLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@ inline_let]
let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in
loop1 h0 bLen res spec
(fun j ->
Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j);
let bj = b.(j) in
res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res
)
[@CInline]
let bn_mul_u32 : bn_mul_st U32 = bn_mul
[@CInline]
let bn_mul_u64 : bn_mul_st U64 = bn_mul
inline_for_extraction noextract
let bn_mul_u (#t:limb_t) : bn_mul_st t =
match t with
| U32 -> bn_mul_u32
| U64 -> bn_mul_u64
inline_for_extraction noextract
val bn_sqr_diag:
#t:limb_t
-> aLen:size_t{v aLen + v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a /\
as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a))
let bn_sqr_diag #t aLen a res =
let h0 = ST.get () in
[@inline_let]
let spec h = SS.bn_sqr_diag_f (as_seq h a) in
loop1 h0 aLen res spec
(fun i ->
Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i);
let (hi, lo) = mul_wide a.(i) a.(i) in
res.(2ul *! i) <- lo;
res.(2ul *! i +! 1ul) <- hi)
// This code is taken from BoringSSL
// https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) =
aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == SS.bn_sqr (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr: #t:limb_t -> bn_sqr_st t
let bn_sqr #t aLen a res =
push_frame ();
[@inline_let]
let resLen = aLen +! aLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@inline_let]
let spec h = SS.bn_sqr_f (as_seq h a) in
loop1 h0 aLen res spec
(fun j ->
Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j);
let ab = sub a 0ul j in
let a_j = a.(j) in
res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res
);
let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in
LowStar.Ignore.ignore c0;
let tmp = create resLen (uint #t 0) in
bn_sqr_diag aLen a tmp;
let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in
LowStar.Ignore.ignore c1;
pop_frame () | false | true | Hacl.Bignum.Multiplication.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sqr_u32:bn_sqr_st U32 | [] | Hacl.Bignum.Multiplication.bn_sqr_u32 | {
"file_name": "code/bignum/Hacl.Bignum.Multiplication.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Multiplication.bn_sqr_st Lib.IntTypes.U32 | {
"end_col": 39,
"end_line": 237,
"start_col": 33,
"start_line": 237
} |
Prims.Tot | val bn_mul_u (#t: limb_t) : bn_mul_st t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Squaring",
"short_module": "SS"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Multiplication",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mul_u (#t:limb_t) : bn_mul_st t =
match t with
| U32 -> bn_mul_u32
| U64 -> bn_mul_u64 | val bn_mul_u (#t: limb_t) : bn_mul_st t
let bn_mul_u (#t: limb_t) : bn_mul_st t = | false | null | false | match t with
| U32 -> bn_mul_u32
| U64 -> bn_mul_u64 | {
"checked_file": "Hacl.Bignum.Multiplication.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Squaring.fst.checked",
"Hacl.Spec.Bignum.Multiplication.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Multiplication.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Multiplication.bn_mul_u32",
"Hacl.Bignum.Multiplication.bn_mul_u64",
"Hacl.Bignum.Multiplication.bn_mul_st"
] | [] | module Hacl.Bignum.Multiplication
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Multiplication
module SS = Hacl.Spec.Bignum.Squaring
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_f (as_seq h a) l in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let h1 = ST.get () in
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i;
lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_lshift_add:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b_j:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in
let h0 = ST.get () in
update_sub_f_carry h0 res j aLen
(fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j))
(fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
inline_for_extraction noextract
let bn_mul_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul: #t:limb_t -> bn_mul_st t
let bn_mul #t aLen a bLen b res =
[@inline_let]
let resLen = aLen +! bLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@ inline_let]
let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in
loop1 h0 bLen res spec
(fun j ->
Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j);
let bj = b.(j) in
res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res
)
[@CInline]
let bn_mul_u32 : bn_mul_st U32 = bn_mul
[@CInline]
let bn_mul_u64 : bn_mul_st U64 = bn_mul
inline_for_extraction noextract | false | false | Hacl.Bignum.Multiplication.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mul_u (#t: limb_t) : bn_mul_st t | [] | Hacl.Bignum.Multiplication.bn_mul_u | {
"file_name": "code/bignum/Hacl.Bignum.Multiplication.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Multiplication.bn_mul_st t | {
"end_col": 21,
"end_line": 165,
"start_col": 2,
"start_line": 163
} |
Prims.Tot | val bn_sqr_u (#t: limb_t) : bn_sqr_st t | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Squaring",
"short_module": "SS"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Multiplication",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sqr_u (#t:limb_t) : bn_sqr_st t =
match t with
| U32 -> bn_sqr_u32
| U64 -> bn_sqr_u64 | val bn_sqr_u (#t: limb_t) : bn_sqr_st t
let bn_sqr_u (#t: limb_t) : bn_sqr_st t = | false | null | false | match t with
| U32 -> bn_sqr_u32
| U64 -> bn_sqr_u64 | {
"checked_file": "Hacl.Bignum.Multiplication.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Squaring.fst.checked",
"Hacl.Spec.Bignum.Multiplication.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Multiplication.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Multiplication.bn_sqr_u32",
"Hacl.Bignum.Multiplication.bn_sqr_u64",
"Hacl.Bignum.Multiplication.bn_sqr_st"
] | [] | module Hacl.Bignum.Multiplication
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module S = Hacl.Spec.Bignum.Multiplication
module SS = Hacl.Spec.Bignum.Squaring
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
let bn_mul1 #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_f (as_seq h a) l in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let h1 = ST.get () in
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i;
lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res))
let bn_mul1_add_in_place #t aLen a l res =
push_frame ();
let c = create 1ul (uint #t 0) in
[@inline_let]
let refl h i = LSeq.index (as_seq h c) 0 in
[@inline_let]
let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\
B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in
[@inline_let]
let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in
let h0 = ST.get () in
fill_elems4 h0 aLen res refl footprint spec
(fun i ->
let a_i = a.(i) in
let res_i = sub res i 1ul in
c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i
);
let c = c.(0ul) in
pop_frame ();
c
inline_for_extraction noextract
val bn_mul1_lshift_add:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b_j:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res))
let bn_mul1_lshift_add #t aLen a b_j resLen j res =
let res_j = sub res j aLen in
let h0 = ST.get () in
update_sub_f_carry h0 res j aLen
(fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j))
(fun _ -> bn_mul1_add_in_place aLen a b_j res_j)
inline_for_extraction noextract
let bn_mul_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul: #t:limb_t -> bn_mul_st t
let bn_mul #t aLen a bLen b res =
[@inline_let]
let resLen = aLen +! bLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@ inline_let]
let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in
loop1 h0 bLen res spec
(fun j ->
Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j);
let bj = b.(j) in
res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res
)
[@CInline]
let bn_mul_u32 : bn_mul_st U32 = bn_mul
[@CInline]
let bn_mul_u64 : bn_mul_st U64 = bn_mul
inline_for_extraction noextract
let bn_mul_u (#t:limb_t) : bn_mul_st t =
match t with
| U32 -> bn_mul_u32
| U64 -> bn_mul_u64
inline_for_extraction noextract
val bn_sqr_diag:
#t:limb_t
-> aLen:size_t{v aLen + v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a /\
as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0))
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a))
let bn_sqr_diag #t aLen a res =
let h0 = ST.get () in
[@inline_let]
let spec h = SS.bn_sqr_diag_f (as_seq h a) in
loop1 h0 aLen res spec
(fun i ->
Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i);
let (hi, lo) = mul_wide a.(i) a.(i) in
res.(2ul *! i) <- lo;
res.(2ul *! i +! 1ul) <- hi)
// This code is taken from BoringSSL
// https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) =
aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == SS.bn_sqr (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr: #t:limb_t -> bn_sqr_st t
let bn_sqr #t aLen a res =
push_frame ();
[@inline_let]
let resLen = aLen +! aLen in
memset res (uint #t 0) resLen;
let h0 = ST.get () in
LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res);
[@inline_let]
let spec h = SS.bn_sqr_f (as_seq h a) in
loop1 h0 aLen res spec
(fun j ->
Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j);
let ab = sub a 0ul j in
let a_j = a.(j) in
res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res
);
let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in
LowStar.Ignore.ignore c0;
let tmp = create resLen (uint #t 0) in
bn_sqr_diag aLen a tmp;
let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in
LowStar.Ignore.ignore c1;
pop_frame ()
[@CInline]
let bn_sqr_u32 : bn_sqr_st U32 = bn_sqr
[@CInline]
let bn_sqr_u64 : bn_sqr_st U64 = bn_sqr
inline_for_extraction noextract | false | false | Hacl.Bignum.Multiplication.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sqr_u (#t: limb_t) : bn_sqr_st t | [] | Hacl.Bignum.Multiplication.bn_sqr_u | {
"file_name": "code/bignum/Hacl.Bignum.Multiplication.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Multiplication.bn_sqr_st t | {
"end_col": 21,
"end_line": 245,
"start_col": 2,
"start_line": 243
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.