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 negate_cond (#t: Type) (cond: (t -> Tot bool)) (x: t) : Tot bool | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let negate_cond
(#t: Type)
(cond: (t -> Tot bool))
(x: t)
: Tot bool
= not (cond x) | val negate_cond (#t: Type) (cond: (t -> Tot bool)) (x: t) : Tot bool
let negate_cond (#t: Type) (cond: (t -> Tot bool)) (x: t) : Tot bool = | false | null | false | not (cond x) | {
"checked_file": "LowParse.Spec.ListUpTo.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.ListUpTo.fsti"
} | [
"total"
] | [
"Prims.bool",
"Prims.op_Negation"
] | [] | module LowParse.Spec.ListUpTo
include LowParse.Spec.Base
module L = FStar.List.Tot
module Seq = FStar.Seq
let negate_cond
(#t: Type)
(cond: (t -> Tot bool))
(x: t) | false | false | LowParse.Spec.ListUpTo.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val negate_cond (#t: Type) (cond: (t -> Tot bool)) (x: t) : Tot bool | [] | LowParse.Spec.ListUpTo.negate_cond | {
"file_name": "src/lowparse/LowParse.Spec.ListUpTo.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | cond: (_: t -> Prims.bool) -> x: t -> Prims.bool | {
"end_col": 14,
"end_line": 12,
"start_col": 2,
"start_line": 12
} |
Prims.Tot | val parse_list_up_to_kind (k: parser_kind) : Tot (k': parser_kind{k' `is_weaker_than` k}) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parse_list_up_to_kind (k: parser_kind) : Tot (k' : parser_kind {k' `is_weaker_than` k }) = {
parser_kind_low = k.parser_kind_low;
parser_kind_high = None;
parser_kind_subkind = k.parser_kind_subkind;
parser_kind_metadata = None;
} | val parse_list_up_to_kind (k: parser_kind) : Tot (k': parser_kind{k' `is_weaker_than` k})
let parse_list_up_to_kind (k: parser_kind) : Tot (k': parser_kind{k' `is_weaker_than` k}) = | false | null | false | {
parser_kind_low = k.parser_kind_low;
parser_kind_high = None;
parser_kind_subkind = k.parser_kind_subkind;
parser_kind_metadata = None
} | {
"checked_file": "LowParse.Spec.ListUpTo.fsti.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.ListUpTo.fsti"
} | [
"total"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.Mkparser_kind'",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"FStar.Pervasives.Native.None",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"LowParse.Spec.Base.parser_kind_metadata_some",
"LowParse.Spec.Base.is_weaker_than"
] | [] | module LowParse.Spec.ListUpTo
include LowParse.Spec.Base
module L = FStar.List.Tot
module Seq = FStar.Seq
let negate_cond
(#t: Type)
(cond: (t -> Tot bool))
(x: t)
: Tot bool
= not (cond x)
let refine_with_cond
(#t: Type)
(cond: (t -> Tot bool))
: Tot Type
= (x: t { cond x == true })
let parse_list_up_to_t
(#t: Type)
(cond: (t -> Tot bool))
: Tot Type
= list (refine_with_cond (negate_cond cond)) & refine_with_cond cond
inline_for_extraction | false | false | LowParse.Spec.ListUpTo.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val parse_list_up_to_kind (k: parser_kind) : Tot (k': parser_kind{k' `is_weaker_than` k}) | [] | LowParse.Spec.ListUpTo.parse_list_up_to_kind | {
"file_name": "src/lowparse/LowParse.Spec.ListUpTo.fsti",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: LowParse.Spec.Base.parser_kind
-> k': LowParse.Spec.Base.parser_kind{LowParse.Spec.Base.is_weaker_than k' k} | {
"end_col": 30,
"end_line": 31,
"start_col": 2,
"start_line": 28
} |
Prims.Tot | val ref (a: Type u#a) (pcm: pcm a) : Type u#0 | [
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref | val ref (a: Type u#a) (pcm: pcm a) : Type u#0
let ref (a: Type u#a) (pcm: pcm a) : Type u#0 = | false | null | false | core_ref | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"FStar.PCM.pcm",
"Steel.Memory.core_ref"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0 | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ref (a: Type u#a) (pcm: pcm a) : Type u#0 | [] | Steel.Memory.ref | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> pcm: FStar.PCM.pcm a -> Type0 | {
"end_col": 54,
"end_line": 115,
"start_col": 46,
"start_line": 115
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hmem (p:slprop u#a) = m:mem u#a {interp p m} | let hmem (p: slprop u#a) = | false | null | false | m: mem u#a {interp p m} | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.mem",
"Steel.Memory.interp"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hmem : p: Steel.Memory.slprop -> Type | [] | Steel.Memory.hmem | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Memory.slprop -> Type | {
"end_col": 48,
"end_line": 91,
"start_col": 26,
"start_line": 91
} |
|
Prims.Tot | val null (#a: Type u#a) (#pcm: pcm a) : ref a pcm | [
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null | val null (#a: Type u#a) (#pcm: pcm a) : ref a pcm
let null (#a: Type u#a) (#pcm: pcm a) : ref a pcm = | false | null | false | core_ref_null | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"FStar.PCM.pcm",
"Steel.Memory.core_ref_null",
"Steel.Memory.ref"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val null (#a: Type u#a) (#pcm: pcm a) : ref a pcm | [] | Steel.Memory.null | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Steel.Memory.ref a pcm | {
"end_col": 63,
"end_line": 123,
"start_col": 50,
"start_line": 123
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let full_mem = m:mem{full_mem_pred m} | let full_mem = | false | null | false | m: mem{full_mem_pred m} | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.mem",
"Steel.Memory.full_mem_pred"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val full_mem : Type | [] | Steel.Memory.full_mem | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Type | {
"end_col": 37,
"end_line": 265,
"start_col": 15,
"start_line": 265
} |
|
Prims.Tot | val a_mem_prop (sl: slprop u#a) : Type u#(a + 1) | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f }) | val a_mem_prop (sl: slprop u#a) : Type u#(a + 1)
let a_mem_prop (sl: slprop u#a) : Type u#(a + 1) = | false | null | false | (f: (hmem sl -> Tot prop){mem_prop_is_affine sl f}) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.hmem",
"Prims.prop",
"Steel.Memory.mem_prop_is_affine"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1))) | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val a_mem_prop (sl: slprop u#a) : Type u#(a + 1) | [] | Steel.Memory.a_mem_prop | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | sl: Steel.Memory.slprop -> Type | {
"end_col": 103,
"end_line": 303,
"start_col": 49,
"start_line": 303
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inames = erased (S.set iname) | let inames = | false | null | false | erased (S.set iname) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Set.set",
"Steel.Memory.iname"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inames : Type0 | [] | Steel.Memory.inames | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Type0 | {
"end_col": 33,
"end_line": 248,
"start_col": 13,
"start_line": 248
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r) | let ptr (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) = | false | null | false | h_exists (pts_to r) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"FStar.PCM.pcm",
"Steel.Memory.ref",
"Steel.Memory.h_exists",
"Steel.Memory.pts_to",
"Steel.Memory.slprop"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ptr : r: Steel.Memory.ref a pcm -> Steel.Memory.slprop | [] | Steel.Memory.ptr | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Memory.ref a pcm -> Steel.Memory.slprop | {
"end_col": 23,
"end_line": 173,
"start_col": 4,
"start_line": 173
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m} | let hmem_with_inv_except (e: inames) (fp: slprop u#a) = | false | null | false | m: full_mem{inames_ok e m /\ interp (fp `star` (locks_invariant e m)) m} | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.inames",
"Steel.Memory.slprop",
"Steel.Memory.full_mem",
"Prims.l_and",
"Steel.Memory.inames_ok",
"Steel.Memory.interp",
"Steel.Memory.star",
"Steel.Memory.locks_invariant"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *) | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hmem_with_inv_except : e: Steel.Memory.inames -> fp: Steel.Memory.slprop -> Type | [] | Steel.Memory.hmem_with_inv_except | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | e: Steel.Memory.inames -> fp: Steel.Memory.slprop -> Type | {
"end_col": 71,
"end_line": 269,
"start_col": 2,
"start_line": 269
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True) | let action_except (a: Type u#a) (except: inames) (expects: slprop) (provides: (a -> slprop)) = | false | null | false | frame: slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.inames",
"Steel.Memory.slprop",
"Steel.Memory.mem",
"Prims.l_True",
"Prims.prop"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val action_except : a: Type ->
except: Steel.Memory.inames ->
expects: Steel.Memory.slprop ->
provides: (_: a -> Steel.Memory.slprop)
-> Type | [] | Steel.Memory.action_except | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
a: Type ->
except: Steel.Memory.inames ->
expects: Steel.Memory.slprop ->
provides: (_: a -> Steel.Memory.slprop)
-> Type | {
"end_col": 92,
"end_line": 406,
"start_col": 2,
"start_line": 406
} |
|
FStar.Pervasives.Lemma | val affine_star_smt (p q: slprop u#a) (m: mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m) [SMTPat (interp (p `star` q) m)] | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m | val affine_star_smt (p q: slprop u#a) (m: mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m) [SMTPat (interp (p `star` q) m)]
let affine_star_smt (p q: slprop u#a) (m: mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m) [SMTPat (interp (p `star` q) m)] = | false | null | true | affine_star p q m | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"lemma"
] | [
"Steel.Memory.slprop",
"Steel.Memory.mem",
"Steel.Memory.affine_star",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_imp",
"Steel.Memory.interp",
"Steel.Memory.star",
"Prims.l_and",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"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 Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val affine_star_smt (p q: slprop u#a) (m: mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m) [SMTPat (interp (p `star` q) m)] | [] | Steel.Memory.affine_star_smt | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Memory.slprop -> q: Steel.Memory.slprop -> m: Steel.Memory.mem
-> FStar.Pervasives.Lemma
(ensures
Steel.Memory.interp (Steel.Memory.star p q) m ==>
Steel.Memory.interp p m /\ Steel.Memory.interp q m)
[SMTPat (Steel.Memory.interp (Steel.Memory.star p q) m)] | {
"end_col": 23,
"end_line": 294,
"start_col": 6,
"start_line": 294
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))} | let mprop2 (#a: Type u#b) (fp_pre: slprop u#a) (fp_post: (a -> slprop u#a)) = | false | null | false | q:
(mem u#a -> a -> mem u#a -> prop)
{ (forall (x: a)
(m0: mem{interp fp_pre m0})
(m_post: mem{interp (fp_post x) m_post})
(m1: mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
(forall (x: a)
(m_pre: mem{interp fp_pre m_pre})
(m0: mem{interp (fp_post x) m0})
(m1: mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1)) } | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.mem",
"Prims.prop",
"Prims.l_and",
"Prims.l_Forall",
"Steel.Memory.interp",
"Steel.Memory.disjoint",
"Prims.l_iff",
"Steel.Memory.join"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)} | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mprop2 : fp_pre: Steel.Memory.slprop -> fp_post: (_: a -> Steel.Memory.slprop) -> Type | [] | Steel.Memory.mprop2 | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | fp_pre: Steel.Memory.slprop -> fp_post: (_: a -> Steel.Memory.slprop) -> Type | {
"end_col": 48,
"end_line": 371,
"start_col": 2,
"start_line": 365
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp | let hmem_with_inv (fp: slprop u#a) = | false | null | false | hmem_with_inv_except S.empty fp | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.hmem_with_inv_except",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m} | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hmem_with_inv : fp: Steel.Memory.slprop -> Type | [] | Steel.Memory.hmem_with_inv | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | fp: Steel.Memory.slprop -> Type | {
"end_col": 67,
"end_line": 272,
"start_col": 36,
"start_line": 272
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens | let action_except_full
(a: Type u#a)
(except: inames)
(expects: slprop)
(provides: (a -> slprop))
(req: mprop expects)
(ens: mprop2 expects provides)
= | false | null | false | frame: slprop -> MstTot a except expects provides frame req ens | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.inames",
"Steel.Memory.slprop",
"Steel.Memory.mprop",
"Steel.Memory.mprop2"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val action_except_full : a: Type ->
except: Steel.Memory.inames ->
expects: Steel.Memory.slprop ->
provides: (_: a -> Steel.Memory.slprop) ->
req: Steel.Memory.mprop expects ->
ens: Steel.Memory.mprop2 expects provides
-> Type | [] | Steel.Memory.action_except_full | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
a: Type ->
except: Steel.Memory.inames ->
expects: Steel.Memory.slprop ->
provides: (_: a -> Steel.Memory.slprop) ->
req: Steel.Memory.mprop expects ->
ens: Steel.Memory.mprop2 expects provides
-> Type | {
"end_col": 64,
"end_line": 414,
"start_col": 2,
"start_line": 414
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)} | let mprop (fp: slprop u#a) = | false | null | false | q:
(mem u#a -> prop)
{forall (m0: mem{interp fp m0}) (m1: mem{disjoint m0 m1}). q m0 <==> q (join m0 m1)} | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.mem",
"Prims.prop",
"Prims.l_Forall",
"Steel.Memory.interp",
"Steel.Memory.disjoint",
"Prims.l_iff",
"Steel.Memory.join"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *) | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mprop : fp: Steel.Memory.slprop -> Type | [] | Steel.Memory.mprop | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | fp: Steel.Memory.slprop -> Type | {
"end_col": 31,
"end_line": 362,
"start_col": 2,
"start_line": 360
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
} | let stable_property (#a: Type) (pcm: pcm a) = | false | null | false | fact: property a {FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)} | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"FStar.PCM.pcm",
"Steel.Memory.property",
"FStar.Preorder.stable",
"Steel.Preorder.preorder_of_pcm"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0 | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val stable_property : pcm: FStar.PCM.pcm a -> Type | [] | Steel.Memory.stable_property | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | pcm: FStar.PCM.pcm a -> Type | {
"end_col": 5,
"end_line": 482,
"start_col": 4,
"start_line": 480
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let property (a:Type)
= a -> prop | let property (a: Type) = | false | null | false | a -> prop | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Prims.prop"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y) | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val property : a: Type -> Type | [] | Steel.Memory.property | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type -> Type | {
"end_col": 13,
"end_line": 471,
"start_col": 4,
"start_line": 471
} |
|
Prims.GTot | val name_of_inv (#p: slprop) (i: inv p) : GTot iname | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let name_of_inv (#p:slprop) (i:inv p)
: GTot iname
= name_of_pre_inv (pre_inv_of_inv i) | val name_of_inv (#p: slprop) (i: inv p) : GTot iname
let name_of_inv (#p: slprop) (i: inv p) : GTot iname = | false | null | false | name_of_pre_inv (pre_inv_of_inv i) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"sometrivial"
] | [
"Steel.Memory.slprop",
"Steel.Memory.inv",
"Steel.Memory.name_of_pre_inv",
"Steel.Memory.pre_inv_of_inv",
"Steel.Memory.iname"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
}
val witness (#a:Type) (#pcm:pcm a)
(e:inames)
(r:erased (ref a pcm))
(fact:stable_property pcm)
(v:Ghost.erased a)
(_:squash (forall z. compatible pcm v z ==> fact z))
: action_except (witnessed r fact) e (pts_to r v) (fun _ -> pts_to r v)
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a)
(e:inames)
(r:erased (ref a pcm))
(v:Ghost.erased a)
(w:witnessed r fact)
: action_except (v1:Ghost.erased a{compatible pcm v v1}) e
(pts_to r v)
(fun v1 -> pts_to r v `star` pure (fact v1))
(**** Invariants *)
(**[i : inv p] is an invariant whose content is [p] *)
val pre_inv : Type0
val inv (p:slprop u#1) : Type0
val pre_inv_of_inv (#p:slprop) (i:inv p) : pre_inv
val name_of_pre_inv (i:pre_inv) : GTot iname
let name_of_inv (#p:slprop) (i:inv p) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val name_of_inv (#p: slprop) (i: inv p) : GTot iname | [] | Steel.Memory.name_of_inv | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | i: Steel.Memory.inv p -> Prims.GTot Steel.Memory.iname | {
"end_col": 38,
"end_line": 514,
"start_col": 4,
"start_line": 514
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fresh_wrt (ctx:list pre_inv)
(i:iname)
= forall i'. List.Tot.memP i' ctx ==> name_of_pre_inv i' <> i | let fresh_wrt (ctx: list pre_inv) (i: iname) = | false | null | false | forall i'. List.Tot.memP i' ctx ==> name_of_pre_inv i' <> i | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Prims.list",
"Steel.Memory.pre_inv",
"Steel.Memory.iname",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Prims.b2t",
"Prims.op_disEquality",
"Steel.Memory.name_of_pre_inv",
"Prims.logical"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
}
val witness (#a:Type) (#pcm:pcm a)
(e:inames)
(r:erased (ref a pcm))
(fact:stable_property pcm)
(v:Ghost.erased a)
(_:squash (forall z. compatible pcm v z ==> fact z))
: action_except (witnessed r fact) e (pts_to r v) (fun _ -> pts_to r v)
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a)
(e:inames)
(r:erased (ref a pcm))
(v:Ghost.erased a)
(w:witnessed r fact)
: action_except (v1:Ghost.erased a{compatible pcm v v1}) e
(pts_to r v)
(fun v1 -> pts_to r v `star` pure (fact v1))
(**** Invariants *)
(**[i : inv p] is an invariant whose content is [p] *)
val pre_inv : Type0
val inv (p:slprop u#1) : Type0
val pre_inv_of_inv (#p:slprop) (i:inv p) : pre_inv
val name_of_pre_inv (i:pre_inv) : GTot iname
let name_of_inv (#p:slprop) (i:inv p)
: GTot iname
= name_of_pre_inv (pre_inv_of_inv i)
let mem_inv (#p:slprop) (e:inames) (i:inv p) : erased bool = elift2 (fun e i -> Set.mem i e) e (name_of_inv i)
let add_inv (#p:slprop) (e:inames) (i:inv p) : inames =
Set.union (Set.singleton (name_of_inv i)) (reveal e)
(** Creates a new invariant from a separation logic predicate [p] owned at the time of the call *)
let fresh_wrt (ctx:list pre_inv) | false | true | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fresh_wrt : ctx: Prims.list Steel.Memory.pre_inv -> i: Steel.Memory.iname -> Prims.logical | [] | Steel.Memory.fresh_wrt | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | ctx: Prims.list Steel.Memory.pre_inv -> i: Steel.Memory.iname -> Prims.logical | {
"end_col": 63,
"end_line": 524,
"start_col": 4,
"start_line": 524
} |
|
Prims.Tot | val add_inv (#p: slprop) (e: inames) (i: inv p) : inames | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_inv (#p:slprop) (e:inames) (i:inv p) : inames =
Set.union (Set.singleton (name_of_inv i)) (reveal e) | val add_inv (#p: slprop) (e: inames) (i: inv p) : inames
let add_inv (#p: slprop) (e: inames) (i: inv p) : inames = | false | null | false | Set.union (Set.singleton (name_of_inv i)) (reveal e) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.inames",
"Steel.Memory.inv",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.union",
"FStar.Set.singleton",
"Steel.Memory.name_of_inv",
"FStar.Ghost.reveal"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
}
val witness (#a:Type) (#pcm:pcm a)
(e:inames)
(r:erased (ref a pcm))
(fact:stable_property pcm)
(v:Ghost.erased a)
(_:squash (forall z. compatible pcm v z ==> fact z))
: action_except (witnessed r fact) e (pts_to r v) (fun _ -> pts_to r v)
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a)
(e:inames)
(r:erased (ref a pcm))
(v:Ghost.erased a)
(w:witnessed r fact)
: action_except (v1:Ghost.erased a{compatible pcm v v1}) e
(pts_to r v)
(fun v1 -> pts_to r v `star` pure (fact v1))
(**** Invariants *)
(**[i : inv p] is an invariant whose content is [p] *)
val pre_inv : Type0
val inv (p:slprop u#1) : Type0
val pre_inv_of_inv (#p:slprop) (i:inv p) : pre_inv
val name_of_pre_inv (i:pre_inv) : GTot iname
let name_of_inv (#p:slprop) (i:inv p)
: GTot iname
= name_of_pre_inv (pre_inv_of_inv i)
let mem_inv (#p:slprop) (e:inames) (i:inv p) : erased bool = elift2 (fun e i -> Set.mem i e) e (name_of_inv i) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add_inv (#p: slprop) (e: inames) (i: inv p) : inames | [] | Steel.Memory.add_inv | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | e: Steel.Memory.inames -> i: Steel.Memory.inv p -> Steel.Memory.inames | {
"end_col": 54,
"end_line": 519,
"start_col": 2,
"start_line": 519
} |
Prims.Tot | val is_frame_monotonic (#a: _) (p: (a -> slprop)) : prop | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_frame_monotonic #a (p : a -> slprop) : prop =
forall x y m frame. interp (p x `star` frame) m /\ interp (p y) m ==> interp (p y `star` frame) m | val is_frame_monotonic (#a: _) (p: (a -> slprop)) : prop
let is_frame_monotonic #a (p: (a -> slprop)) : prop = | false | null | false | forall x y m frame.
interp ((p x) `star` frame) m /\ interp (p y) m ==> interp ((p y) `star` frame) m | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Prims.l_Forall",
"Steel.Memory.mem",
"Prims.l_imp",
"Prims.l_and",
"Steel.Memory.interp",
"Steel.Memory.star",
"Prims.prop"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
}
val witness (#a:Type) (#pcm:pcm a)
(e:inames)
(r:erased (ref a pcm))
(fact:stable_property pcm)
(v:Ghost.erased a)
(_:squash (forall z. compatible pcm v z ==> fact z))
: action_except (witnessed r fact) e (pts_to r v) (fun _ -> pts_to r v)
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a)
(e:inames)
(r:erased (ref a pcm))
(v:Ghost.erased a)
(w:witnessed r fact)
: action_except (v1:Ghost.erased a{compatible pcm v v1}) e
(pts_to r v)
(fun v1 -> pts_to r v `star` pure (fact v1))
(**** Invariants *)
(**[i : inv p] is an invariant whose content is [p] *)
val pre_inv : Type0
val inv (p:slprop u#1) : Type0
val pre_inv_of_inv (#p:slprop) (i:inv p) : pre_inv
val name_of_pre_inv (i:pre_inv) : GTot iname
let name_of_inv (#p:slprop) (i:inv p)
: GTot iname
= name_of_pre_inv (pre_inv_of_inv i)
let mem_inv (#p:slprop) (e:inames) (i:inv p) : erased bool = elift2 (fun e i -> Set.mem i e) e (name_of_inv i)
let add_inv (#p:slprop) (e:inames) (i:inv p) : inames =
Set.union (Set.singleton (name_of_inv i)) (reveal e)
(** Creates a new invariant from a separation logic predicate [p] owned at the time of the call *)
let fresh_wrt (ctx:list pre_inv)
(i:iname)
= forall i'. List.Tot.memP i' ctx ==> name_of_pre_inv i' <> i
val fresh_invariant (e:inames) (p:slprop) (ctx:list pre_inv)
: action_except (i:inv p { not (mem_inv e i) /\ fresh_wrt ctx (name_of_inv i) }) e p (fun _ -> emp)
val new_invariant (e:inames) (p:slprop)
: action_except (inv p) e p (fun _ -> emp)
val with_invariant (#a:Type)
(#fp:slprop)
(#fp':a -> slprop)
(#opened_invariants:inames)
(#p:slprop)
(i:inv p{not (mem_inv opened_invariants i)})
(f:action_except a (add_inv opened_invariants i) (p `star` fp) (fun x -> p `star` fp' x))
: action_except a opened_invariants fp fp'
val frame (#a:Type)
(#opened_invariants:inames)
(#pre:slprop)
(#post:a -> slprop)
(#req:mprop pre)
(#ens:mprop2 pre post)
(frame:slprop)
($f:action_except_full a opened_invariants pre post req ens)
: action_except_full a opened_invariants (pre `star` frame) (fun x -> post x `star` frame) req ens
val change_slprop (#opened_invariants:inames)
(p q:slprop)
(proof: (m:mem -> Lemma (requires interp p m) (ensures interp q m)))
: action_except unit opened_invariants p (fun _ -> q)
module U = FStar.Universe | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_frame_monotonic (#a: _) (p: (a -> slprop)) : prop | [] | Steel.Memory.is_frame_monotonic | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: (_: a -> Steel.Memory.slprop) -> Prims.prop | {
"end_col": 99,
"end_line": 560,
"start_col": 2,
"start_line": 560
} |
Prims.Tot | val mem_inv (#p: slprop) (e: inames) (i: inv p) : erased bool | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mem_inv (#p:slprop) (e:inames) (i:inv p) : erased bool = elift2 (fun e i -> Set.mem i e) e (name_of_inv i) | val mem_inv (#p: slprop) (e: inames) (i: inv p) : erased bool
let mem_inv (#p: slprop) (e: inames) (i: inv p) : erased bool = | false | null | false | elift2 (fun e i -> Set.mem i e) e (name_of_inv i) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.inames",
"Steel.Memory.inv",
"FStar.Ghost.elift2",
"FStar.Set.set",
"Steel.Memory.iname",
"Prims.bool",
"FStar.Set.mem",
"FStar.Ghost.hide",
"Steel.Memory.name_of_inv",
"FStar.Ghost.erased"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
}
val witness (#a:Type) (#pcm:pcm a)
(e:inames)
(r:erased (ref a pcm))
(fact:stable_property pcm)
(v:Ghost.erased a)
(_:squash (forall z. compatible pcm v z ==> fact z))
: action_except (witnessed r fact) e (pts_to r v) (fun _ -> pts_to r v)
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a)
(e:inames)
(r:erased (ref a pcm))
(v:Ghost.erased a)
(w:witnessed r fact)
: action_except (v1:Ghost.erased a{compatible pcm v v1}) e
(pts_to r v)
(fun v1 -> pts_to r v `star` pure (fact v1))
(**** Invariants *)
(**[i : inv p] is an invariant whose content is [p] *)
val pre_inv : Type0
val inv (p:slprop u#1) : Type0
val pre_inv_of_inv (#p:slprop) (i:inv p) : pre_inv
val name_of_pre_inv (i:pre_inv) : GTot iname
let name_of_inv (#p:slprop) (i:inv p)
: GTot iname
= name_of_pre_inv (pre_inv_of_inv i) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mem_inv (#p: slprop) (e: inames) (i: inv p) : erased bool | [] | Steel.Memory.mem_inv | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | e: Steel.Memory.inames -> i: Steel.Memory.inv p -> FStar.Ghost.erased Prims.bool | {
"end_col": 110,
"end_line": 516,
"start_col": 61,
"start_line": 516
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_witness_invariant #a (p : a -> slprop) =
forall x y m. interp (p x) m /\ interp (p y) m ==> x == y | let is_witness_invariant #a (p: (a -> slprop)) = | false | null | false | forall x y m. interp (p x) m /\ interp (p y) m ==> x == y | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Prims.l_Forall",
"Steel.Memory.mem",
"Prims.l_imp",
"Prims.l_and",
"Steel.Memory.interp",
"Prims.eq2",
"Prims.logical"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h))
val interp_sdep
(s: slprop)
(f: (hmem s -> Tot slprop))
(m: mem)
: Lemma
(requires (dep_slprop_is_affine s f))
(ensures (
interp (sdep s f) m <==> (exists m1 m2 . interp s m1 /\ interp (f m1) m2 /\ disjoint m1 m2 /\ join m1 m2 == m)
))
[SMTPat (interp (sdep s f) m)]
(** See [Steel.Heap.h_exists_cong] *)
val h_exists_cong (#a:Type) (p q : a -> slprop)
: Lemma
(requires (forall x. p x `equiv` q x))
(ensures (h_exists p `equiv` h_exists q))
(** Introducing [h_exists] by presenting a witness *)
val intro_h_exists (#a:_) (x:a) (p:a -> slprop) (m:mem)
: Lemma (interp (p x) m ==> interp (h_exists p) m)
val elim_h_exists (#a:_) (p:a -> slprop) (m:mem)
: Lemma (interp (h_exists p) m ==> (exists x. interp (p x) m))
(**** Actions *)
/// Note, at this point, using the NMSTTotal effect constrains the mem to be
/// in universe 2, rather than being universe polymorphic
(** A memory predicate that depends only on fp *)
let mprop (fp:slprop u#a) =
q:(mem u#a -> prop){
forall (m0:mem{interp fp m0}) (m1:mem{disjoint m0 m1}).
q m0 <==> q (join m0 m1)}
let mprop2 (#a:Type u#b) (fp_pre:slprop u#a) (fp_post:a -> slprop u#a) =
q:(mem u#a -> a -> mem u#a -> prop){
// can join any disjoint mem to the pre-mem and q is still valid
(forall (x:a) (m0:mem{interp fp_pre m0}) (m_post:mem{interp (fp_post x) m_post}) (m1:mem{disjoint m0 m1}).
q m0 x m_post <==> q (join m0 m1) x m_post) /\
// can join any mem to the post-mem and q is still valid
(forall (x:a) (m_pre:mem{interp fp_pre m_pre}) (m0:mem{interp (fp_post x) m0}) (m1:mem{disjoint m0 m1}).
q m_pre x m0 <==> q m_pre x (join m0 m1))}
(**
The preorder along which the memory evolves with every update. See [Steel.Heap.heap_evolves]
*)
val mem_evolves : FStar.Preorder.preorder full_mem
(**
To guarantee that the memory always evolve according to frame-preserving updates,
we encode it into the [MstTot] effect build on top of the non-deterministic state total
effect NMSTATETOT. The effect is indexed by [except], which is the set of invariants that
are currently opened.
*)
effect MstTot
(a:Type u#a)
(except:inames)
(expects:slprop u#1)
(provides: a -> slprop u#1)
(frame:slprop u#1)
(pre:mprop expects)
(post:mprop2 expects provides)
= NMSTTotal.NMSTATETOT a (full_mem u#1) mem_evolves
(requires fun m0 ->
inames_ok except m0 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\
pre (core_mem m0))
(ensures fun m0 x m1 ->
inames_ok except m1 /\
interp (expects `star` frame `star` locks_invariant except m0) m0 /\ //TODO: fix the effect so as not to repeat this
interp (provides x `star` frame `star` locks_invariant except m1) m1 /\
post (core_mem m0) x (core_mem m1) /\
(forall (f_frame:mprop frame). f_frame (core_mem m0) == f_frame (core_mem m1)))
(** An action is just a thunked computation in [MstTot] that takes a frame as argument *)
let action_except (a:Type u#a) (except:inames) (expects:slprop) (provides: a -> slprop) =
frame:slprop -> MstTot a except expects provides frame (fun _ -> True) (fun _ _ _ -> True)
let action_except_full (a:Type u#a)
(except:inames)
(expects:slprop)
(provides: a -> slprop)
(req:mprop expects)
(ens:mprop2 expects provides)
= frame:slprop -> MstTot a except expects provides frame req ens
val sel_action (#a:Type u#1) (#pcm:_) (e:inames) (r:ref a pcm) (v0:erased a)
: action_except (v:a{compatible pcm v0 v}) e (pts_to r v0) (fun _ -> pts_to r v0)
val upd_action (#a:Type u#1) (#pcm:_) (e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:a {FStar.PCM.frame_preserving pcm v0 v1 /\ pcm.refine v1})
: action_except unit e (pts_to r v0) (fun _ -> pts_to r v1)
val free_action (#a:Type u#1) (#pcm:pcm a) (e:inames)
(r:ref a pcm) (x:FStar.Ghost.erased a{FStar.PCM.exclusive pcm x /\ pcm.refine pcm.FStar.PCM.p.one})
: action_except unit e (pts_to r x) (fun _ -> pts_to r pcm.FStar.PCM.p.one)
(** Splitting a permission on a composite resource into two separate permissions *)
val split_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a{composable pcm v0 v1})
: action_except unit e (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 `star` pts_to r v1)
(** Combining separate permissions into a single composite permission *)
val gather_action
(#a:Type u#1)
(#pcm:pcm a)
(e:inames)
(r:ref a pcm)
(v0:FStar.Ghost.erased a)
(v1:FStar.Ghost.erased a)
: action_except (_:unit{composable pcm v0 v1}) e (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val alloc_action (#a:Type u#1) (#pcm:pcm a) (e:inames) (x:a{compatible pcm x x /\ pcm.refine x})
: action_except (ref a pcm) e emp (fun r -> pts_to r x)
val select_refine (#a:Type u#1) (#p:pcm a)
(e:inames)
(r:ref a p)
(x:erased a)
(f:(v:a{compatible p x v}
-> GTot (y:a{compatible p y v /\
FStar.PCM.frame_compatible p x v y})))
: action_except (v:a{compatible p x v /\ p.refine v}) e
(pts_to r x)
(fun v -> pts_to r (f v))
val upd_gen (#a:Type) (#p:pcm a) (e:inames) (r:ref a p) (x y:Ghost.erased a)
(f:FStar.PCM.frame_preserving_upd p x y)
: action_except unit e
(pts_to r x)
(fun _ -> pts_to r y)
let property (a:Type)
= a -> prop
val witnessed (#a:Type u#1)
(#pcm:pcm a)
(r:ref a pcm)
(fact:property a)
: Type0
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (Steel.Preorder.preorder_of_pcm pcm)
}
val witness (#a:Type) (#pcm:pcm a)
(e:inames)
(r:erased (ref a pcm))
(fact:stable_property pcm)
(v:Ghost.erased a)
(_:squash (forall z. compatible pcm v z ==> fact z))
: action_except (witnessed r fact) e (pts_to r v) (fun _ -> pts_to r v)
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a)
(e:inames)
(r:erased (ref a pcm))
(v:Ghost.erased a)
(w:witnessed r fact)
: action_except (v1:Ghost.erased a{compatible pcm v v1}) e
(pts_to r v)
(fun v1 -> pts_to r v `star` pure (fact v1))
(**** Invariants *)
(**[i : inv p] is an invariant whose content is [p] *)
val pre_inv : Type0
val inv (p:slprop u#1) : Type0
val pre_inv_of_inv (#p:slprop) (i:inv p) : pre_inv
val name_of_pre_inv (i:pre_inv) : GTot iname
let name_of_inv (#p:slprop) (i:inv p)
: GTot iname
= name_of_pre_inv (pre_inv_of_inv i)
let mem_inv (#p:slprop) (e:inames) (i:inv p) : erased bool = elift2 (fun e i -> Set.mem i e) e (name_of_inv i)
let add_inv (#p:slprop) (e:inames) (i:inv p) : inames =
Set.union (Set.singleton (name_of_inv i)) (reveal e)
(** Creates a new invariant from a separation logic predicate [p] owned at the time of the call *)
let fresh_wrt (ctx:list pre_inv)
(i:iname)
= forall i'. List.Tot.memP i' ctx ==> name_of_pre_inv i' <> i
val fresh_invariant (e:inames) (p:slprop) (ctx:list pre_inv)
: action_except (i:inv p { not (mem_inv e i) /\ fresh_wrt ctx (name_of_inv i) }) e p (fun _ -> emp)
val new_invariant (e:inames) (p:slprop)
: action_except (inv p) e p (fun _ -> emp)
val with_invariant (#a:Type)
(#fp:slprop)
(#fp':a -> slprop)
(#opened_invariants:inames)
(#p:slprop)
(i:inv p{not (mem_inv opened_invariants i)})
(f:action_except a (add_inv opened_invariants i) (p `star` fp) (fun x -> p `star` fp' x))
: action_except a opened_invariants fp fp'
val frame (#a:Type)
(#opened_invariants:inames)
(#pre:slprop)
(#post:a -> slprop)
(#req:mprop pre)
(#ens:mprop2 pre post)
(frame:slprop)
($f:action_except_full a opened_invariants pre post req ens)
: action_except_full a opened_invariants (pre `star` frame) (fun x -> post x `star` frame) req ens
val change_slprop (#opened_invariants:inames)
(p q:slprop)
(proof: (m:mem -> Lemma (requires interp p m) (ensures interp q m)))
: action_except unit opened_invariants p (fun _ -> q)
module U = FStar.Universe
let is_frame_monotonic #a (p : a -> slprop) : prop =
forall x y m frame. interp (p x `star` frame) m /\ interp (p y) m ==> interp (p y `star` frame) m | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_witness_invariant : p: (_: a -> Steel.Memory.slprop) -> Prims.logical | [] | Steel.Memory.is_witness_invariant | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: (_: a -> Steel.Memory.slprop) -> Prims.logical | {
"end_col": 59,
"end_line": 563,
"start_col": 2,
"start_line": 563
} |
|
Prims.Tot | val is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null}) | [
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r | val is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null})
let is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null}) = | false | null | false | core_ref_is_null r | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"FStar.PCM.pcm",
"Steel.Memory.ref",
"Steel.Memory.core_ref_is_null",
"Prims.bool",
"Prims.l_iff",
"Prims.b2t",
"Prims.eq2",
"Steel.Memory.null"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null] | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_null (#a: Type u#a) (#pcm: pcm a) (r: ref a pcm) : (b: bool{b <==> r == null}) | [] | Steel.Memory.is_null | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | r: Steel.Memory.ref a pcm -> b: Prims.bool{b <==> r == Steel.Memory.null} | {
"end_col": 102,
"end_line": 129,
"start_col": 84,
"start_line": 129
} |
Prims.Tot | val mem_prop_is_affine (sl: slprop u#a) (f: (hmem sl -> Tot prop)) : Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1))) | val mem_prop_is_affine (sl: slprop u#a) (f: (hmem sl -> Tot prop)) : Tot prop
let mem_prop_is_affine (sl: slprop u#a) (f: (hmem sl -> Tot prop)) : Tot prop = | false | null | false | (forall m. f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1. (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1))) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.hmem",
"Prims.prop",
"Prims.l_and",
"Prims.l_Forall",
"Steel.Memory.mem",
"Steel.Memory.interp",
"Prims.l_iff",
"Steel.Memory.core_mem",
"Steel.Memory.disjoint",
"Prims.l_imp",
"Steel.Memory.join"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop)) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mem_prop_is_affine (sl: slprop u#a) (f: (hmem sl -> Tot prop)) : Tot prop | [] | Steel.Memory.mem_prop_is_affine | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | sl: Steel.Memory.slprop -> f: (_: Steel.Memory.hmem sl -> Prims.prop) -> Prims.prop | {
"end_col": 103,
"end_line": 301,
"start_col": 2,
"start_line": 300
} |
Prims.Tot | val dep_slprop_is_affine (s: slprop) (f: (hmem s -> Tot slprop)) : Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Set",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop))
: Tot prop
= (forall (h: hmem s) . f h `equiv` f (core_mem h)) | val dep_slprop_is_affine (s: slprop) (f: (hmem s -> Tot slprop)) : Tot prop
let dep_slprop_is_affine (s: slprop) (f: (hmem s -> Tot slprop)) : Tot prop = | false | null | false | (forall (h: hmem s). (f h) `equiv` (f (core_mem h))) | {
"checked_file": "Steel.Memory.fsti.checked",
"dependencies": [
"Steel.Preorder.fst.checked",
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Memory.fsti"
} | [
"total"
] | [
"Steel.Memory.slprop",
"Steel.Memory.hmem",
"Prims.l_Forall",
"Steel.Memory.equiv",
"Steel.Memory.core_mem",
"Prims.prop"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Memory
open FStar.Ghost
open FStar.PCM
/// Building up on `Steel.Heap`, this module adds memory invariants to the heap to expose the
/// final interface for Steel's PCM-based memory model.
(**** Basic memory properties *)
(** Abstract type of memories *)
val mem : Type u#(a + 1)
(**
The memory is built on top of the heap, adding on the memory invariants. However, some of the
properties exposed for memories need only to talk about the underlying heap, putting aside
the memory invariants. To avoid exposing the underlying heap in this abstract interface, we
prefer to relying on this [core_mem] function that returns a new memory sharing the same
heap with the original memory but without any of the memory invariants.
*)
val core_mem (m:mem u#a) : mem u#a
val core_mem_invol (m: mem u#a) : Lemma
(core_mem (core_mem m) == core_mem m)
[SMTPat (core_mem (core_mem m))]
(** A predicate describing non-overlapping memories. Based on [Steel.Heap.disjoint] *)
val disjoint (m0 m1:mem u#h) : prop
(** Disjointness is symmetric *)
val disjoint_sym (m0 m1:mem u#h)
: Lemma (disjoint m0 m1 <==> disjoint m1 m0)
[SMTPat (disjoint m0 m1)]
(** Disjoint memories can be combined. Based on [Steel.Heap.join] *)
val join (m0:mem u#h) (m1:mem u#h{disjoint m0 m1}) : mem u#h
(** Join is commutative *)
val join_commutative (m0 m1:mem)
: Lemma
(requires
disjoint m0 m1)
(ensures
(disjoint m0 m1 /\
disjoint m1 m0 /\
join m0 m1 == join m1 m0))
(** Disjointness distributes over join *)
val disjoint_join (m0 m1 m2:mem)
: Lemma (disjoint m1 m2 /\
disjoint m0 (join m1 m2) ==>
disjoint m0 m1 /\
disjoint m0 m2 /\
disjoint (join m0 m1) m2 /\
disjoint (join m0 m2) m1)
(** Join is associative *)
val join_associative (m0 m1 m2:mem)
: Lemma
(requires
disjoint m1 m2 /\
disjoint m0 (join m1 m2))
(ensures
(disjoint_join m0 m1 m2;
join m0 (join m1 m2) == join (join m0 m1) m2))
(**** Separation logic *)
(** The type of separation logic propositions. Based on Steel.Heap.slprop *)
[@@erasable]
val slprop : Type u#(a + 1)
(** Interpreting mem assertions as memory predicates *)
val interp (p:slprop u#a) (m:mem u#a) : prop
(** A common abbreviation: memories validating [p] *)
let hmem (p:slprop u#a) = m:mem u#a {interp p m}
(** Equivalence relation on slprops is just equivalence of their interpretations *)
val equiv (p1 p2:slprop u#a) : prop
(**
An extensional equivalence principle for slprop
*)
val slprop_extensionality (p q:slprop)
: Lemma
(requires p `equiv` q)
(ensures p == q)
val reveal_equiv (p1 p2:slprop u#a) : Lemma
(ensures (forall m. interp p1 m <==> interp p2 m) <==> p1 `equiv` p2)
[SMTPat (p1 `equiv` p2)]
(** Implication of slprops *)
let slimp (p1 p2 : slprop) : prop =
forall m. interp p1 m ==> interp p2 m
(** A memory maps a [ref]erence to its associated value *)
val core_ref : Type u#0
let ref (a:Type u#a) (pcm:pcm a) : Type u#0 = core_ref
(** [null] is a specific reference, that is not associated to any value
*)
val core_ref_null : core_ref
(** [null] is a specific reference, that is not associated to any value
*)
let null (#a:Type u#a) (#pcm:pcm a) : ref a pcm = core_ref_null
val core_ref_is_null (r:core_ref) : b:bool { b <==> r == core_ref_null }
(** Checking whether [r] is the null pointer is decidable through [is_null]
*)
let is_null (#a:Type u#a) (#pcm:pcm a) (r:ref a pcm) : (b:bool{b <==> r == null}) = core_ref_is_null r
(** All the standard connectives of separation logic, based on [Steel.Heap] *)
val emp : slprop u#a
val pure (p:prop) : slprop u#a
val pts_to (#a:Type u#a) (#pcm:_) (r:ref a pcm) (v:a) : slprop u#a
val h_and (p1 p2:slprop u#a) : slprop u#a
val h_or (p1 p2:slprop u#a) : slprop u#a
val star (p1 p2:slprop u#a) : slprop u#a
val wand (p1 p2:slprop u#a) : slprop u#a
val h_exists (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
val h_forall (#a:Type u#b) (f: (a -> slprop u#a)) : slprop u#a
(***** Properties of separation logic equivalence *)
val equiv_symmetric (p1 p2:slprop)
: squash (p1 `equiv` p2 ==> p2 `equiv` p1)
val equiv_extensional_on_star (p1 p2 p3:slprop)
: squash (p1 `equiv` p2 ==> (p1 `star` p3) `equiv` (p2 `star` p3))
val emp_unit (p:slprop)
: Lemma (p `equiv` (p `star` emp))
val intro_emp (m:mem)
: Lemma (interp emp m)
(** Equivalence of pure propositions is the equivalence of the underlying propositions *)
val pure_equiv (p q:prop)
: Lemma ((p <==> q) ==> (pure p `equiv` pure q))
(** And the interpretation of pure propositions is their underlying propositions *)
val pure_interp (q:prop) (m:mem)
: Lemma (interp (pure q) m <==> q)
(** A helper lemma for interpreting a pure proposition with another [slprop] *)
val pure_star_interp (p:slprop u#a) (q:prop) (m:mem)
: Lemma (interp (p `star` pure q) m <==>
interp (p `star` emp) m /\ q)
(***** Properties of [pts_to] *)
(** [ptr r] asserts that the reference [r] points to a value *)
let ptr (#a: Type u#a) (#pcm: pcm a) (r:ref a pcm) =
h_exists (pts_to r)
(** Injectivity-like lemma for [pts_to], see [Steel.Heap] for more explanations *)
val pts_to_compatible
(#a:Type u#a)
(#pcm:pcm a)
(x:ref a pcm)
(v0 v1:a)
(m:mem u#a)
: Lemma
(interp (pts_to x v0 `star` pts_to x v1) m <==>
composable pcm v0 v1 /\ interp (pts_to x (op pcm v0 v1)) m)
val pts_to_compatible_equiv (#a:Type)
(#pcm:_)
(x:ref a pcm)
(v0:a)
(v1:a{composable pcm v0 v1})
: Lemma (equiv (pts_to x v0 `star` pts_to x v1)
(pts_to x (op pcm v0 v1)))
val pts_to_not_null (#a:Type u#a)
(#pcm:_)
(x:ref a pcm)
(v:a)
(m:mem u#a)
: Lemma (requires interp (pts_to x v) m)
(ensures x =!= null)
(***** Properties of the separating conjunction *)
/// See [Steel.Memory.Heap] for more explanations
val intro_star (p q:slprop) (mp:hmem p) (mq:hmem q)
: Lemma
(requires
disjoint mp mq)
(ensures
interp (p `star` q) (join mp mq))
val elim_star (p q:slprop) (m:hmem (p `star` q))
: Lemma
(requires
interp (p `star` q) m)
(ensures exists ml mr.
disjoint ml mr /\ m == join ml mr /\ interp p ml /\ interp q mr)
val interp_star
(p q: slprop)
(m: mem)
: Lemma
(interp (p `star` q) m <==> (exists (mp: mem) (mq: mem) . disjoint mp mq /\ interp p mp /\ interp q mq /\ join mp mq == m))
val star_commutative (p1 p2:slprop)
: Lemma ((p1 `star` p2) `equiv` (p2 `star` p1))
val star_associative (p1 p2 p3:slprop)
: Lemma ((p1 `star` (p2 `star` p3))
`equiv`
((p1 `star` p2) `star` p3))
val star_congruence (p1 p2 p3 p4:slprop)
: Lemma (requires p1 `equiv` p3 /\ p2 `equiv` p4)
(ensures (p1 `star` p2) `equiv` (p3 `star` p4))
val affine_star (p q:slprop) (m:mem)
: Lemma ((interp (p `star` q) m ==> interp p m /\ interp q m))
(**** Memory invariants *)
module S = FStar.Set
(** Invariants have a name *)
val iname : eqtype
let inames = erased (S.set iname)
(** This proposition tells us that all the invariants names in [e] are valid in memory [m] *)
val inames_ok (e:inames) (m:mem) : prop
(** The empty set of invariants is always empty *)
val inames_ok_empty (m:mem)
: Lemma (ensures inames_ok Set.empty m)
[SMTPat (inames_ok Set.empty m)]
(**
This separation logic proposition asserts that all the invariants whose names are in [e]
are in effect and satisfied on the heap inside the memory [m]
*)
val locks_invariant (e:inames) (m:mem u#a) : slprop u#a
val full_mem_pred: mem -> prop
let full_mem = m:mem{full_mem_pred m}
(** Memory refined with invariants and a footprint *)
let hmem_with_inv_except (e:inames) (fp:slprop u#a) =
m:full_mem{inames_ok e m /\ interp (fp `star` locks_invariant e m) m}
(** Memory refined with just a footprint and no invariants *)
let hmem_with_inv (fp:slprop u#a) = hmem_with_inv_except S.empty fp
/// The following lemmas are needed in `Steel.Effect`
(** Any separation logic proposition valid over [m] is also valid on [core_mem m] *)
val core_mem_interp (hp:slprop u#a) (m:mem u#a)
: Lemma
(requires True)
(ensures (interp hp (core_mem m) <==> interp hp m))
[SMTPat (interp hp (core_mem m))]
(** Interpretation is an affine heap proposition. See [Steel.Heap.interp_depends_only_on] *)
val interp_depends_only_on (hp:slprop u#a)
: Lemma
(forall (m0:hmem hp) (m1:mem u#a{disjoint m0 m1}).
interp hp m0 <==> interp hp (join m0 m1))
(** This adds a SMT trigger to the [Steel.Heap.affine_star] lemma *)
let affine_star_smt (p q:slprop u#a) (m:mem u#a)
: Lemma (interp (p `star` q) m ==> interp p m /\ interp q m)
[SMTPat (interp (p `star` q) m)]
= affine_star p q m
let mem_prop_is_affine
(sl: slprop u#a)
(f: (hmem sl -> Tot prop))
: Tot prop
= (forall m . f m <==> f (core_mem m)) /\
(forall (m0: hmem sl) m1 . (disjoint m0 m1 /\ interp sl (join m0 m1)) ==> (f m0 <==> f (join m0 m1)))
let a_mem_prop (sl: slprop u#a) : Type u#(a+1) = (f: (hmem sl -> Tot prop) { mem_prop_is_affine sl f })
val refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
: Tot (slprop u#a)
val interp_refine_slprop
(sl: slprop u#a)
(f: a_mem_prop sl)
(m: mem u#a)
: Lemma
(interp (refine_slprop sl f) m <==> (interp sl m /\ f m))
[SMTPat (interp (refine_slprop sl f) m)]
val sdep
(s: slprop u#a)
(f: (hmem s -> Tot (slprop u#a)))
: Tot (slprop u#a)
let dep_slprop_is_affine
(s: slprop)
(f: (hmem s -> Tot slprop)) | false | false | Steel.Memory.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val dep_slprop_is_affine (s: slprop) (f: (hmem s -> Tot slprop)) : Tot prop | [] | Steel.Memory.dep_slprop_is_affine | {
"file_name": "lib/steel/Steel.Memory.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | s: Steel.Memory.slprop -> f: (_: Steel.Memory.hmem s -> Steel.Memory.slprop) -> Prims.prop | {
"end_col": 52,
"end_line": 327,
"start_col": 2,
"start_line": 327
} |
Prims.Tot | val t_at_most (n:U32.t) (t:Type u#r) : Type u#r | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 t_at_most (n:U32.t) (t:Type) = t & all_bytes | val t_at_most (n:U32.t) (t:Type u#r) : Type u#r
let t_at_most (n: U32.t) (t: Type) = | false | null | false | t & all_bytes | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"FStar.Pervasives.Native.tuple2",
"EverParse3d.Prelude.all_bytes"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
//////////////////////////////////////////////////////////////////////////////// | false | true | EverParse3d.Prelude.fst | {
"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 t_at_most (n:U32.t) (t:Type u#r) : Type u#r | [] | EverParse3d.Prelude.t_at_most | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> t: Type -> Type | {
"end_col": 48,
"end_line": 122,
"start_col": 35,
"start_line": 122
} |
Prims.Tot | 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) ) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2 | 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) )
let parse_dep_pair p1 p2 = | false | null | false | LPC.parse_dtuple2 p1 p2 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"EverParse3d.Prelude.parser",
"EverParse3d.Kinds.weak_kind",
"LowParse.Spec.Combinators.parse_dtuple2",
"Prims.op_BarBar",
"EverParse3d.Kinds.and_then_kind",
"Prims.dtuple2"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_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) ) | [] | EverParse3d.Prelude.parse_dep_pair | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p1: EverParse3d.Prelude.parser k1 t1 -> p2: (x: t1 -> EverParse3d.Prelude.parser k2 (t2 x))
-> EverParse3d.Prelude.parser (EverParse3d.Kinds.and_then_kind k1 k2) (Prims.dtuple2 t1 t2) | {
"end_col": 27,
"end_line": 59,
"start_col": 4,
"start_line": 59
} |
Prims.Tot | val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 parser k t = LP.parser k t | val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r
let parser k t = | false | null | false | LP.parser k t | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"LowParse.Spec.Base.parser"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
//////////////////////////////////////////////////////////////////////////////// | false | false | EverParse3d.Prelude.fst | {
"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 parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r | [] | EverParse3d.Prelude.parser | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: EverParse3d.Kinds.parser_kind nz wk -> t: Type -> Type | {
"end_col": 30,
"end_line": 31,
"start_col": 17,
"start_line": 31
} |
Prims.Tot | val nlist (n:U32.t) (t:Type u#r) : Type u#r | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 nlist (n:U32.t) (t:Type) = list t | val nlist (n:U32.t) (t:Type u#r) : Type u#r
let nlist (n: U32.t) (t: Type) = | false | null | false | list t | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.list"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 () | false | true | EverParse3d.Prelude.fst | {
"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 nlist (n:U32.t) (t:Type u#r) : Type u#r | [] | EverParse3d.Prelude.nlist | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> t: Type -> Type | {
"end_col": 37,
"end_line": 101,
"start_col": 31,
"start_line": 101
} |
Prims.Tot | [
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 injective_map a b = (a -> Tot b) | let injective_map a b = | false | null | false | (a -> Tot b) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2 | false | true | EverParse3d.Prelude.fst | {
"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 injective_map : a: Type -> b: Type -> Type | [] | EverParse3d.Prelude.injective_map | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | a: Type -> b: Type -> Type | {
"end_col": 36,
"end_line": 67,
"start_col": 24,
"start_line": 67
} |
|
Prims.Tot | 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)) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_filter p f
= LPC.parse_filter p f | 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))
let parse_filter p f = | false | null | false | LPC.parse_filter p f | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"LowParse.Spec.Combinators.parse_filter",
"EverParse3d.Kinds.filter_kind",
"EverParse3d.Prelude.refine"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool))
: Tot (parser (filter_kind k) (refine t f)) | [] | EverParse3d.Prelude.parse_filter | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p: EverParse3d.Prelude.parser k t -> f: (_: t -> Prims.bool)
-> EverParse3d.Prelude.parser (EverParse3d.Kinds.filter_kind k) (EverParse3d.Prelude.refine t f) | {
"end_col": 24,
"end_line": 71,
"start_col": 4,
"start_line": 71
} |
Prims.Tot | val read____UINT32 : reader parse____UINT32 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT32 = LowParse.Low.BoundedInt.read_u32_le | val read____UINT32 : reader parse____UINT32
let read____UINT32 = | false | null | false | LowParse.Low.BoundedInt.read_u32_le | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.BoundedInt.read_u32_le"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64
/// UInt16
let parse____UINT16 = LowParse.Spec.BoundedInt.parse_u16_le
let read____UINT16 = LowParse.Low.BoundedInt.read_u16_le
/// UInt32 | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT32 : reader parse____UINT32 | [] | EverParse3d.Prelude.read____UINT32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT32 | {
"end_col": 56,
"end_line": 306,
"start_col": 21,
"start_line": 306
} |
Prims.Tot | 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)) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_pair p1 p2
= LPC.nondep_then p1 p2 | 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))
let parse_pair p1 p2 = | false | null | false | LPC.nondep_then p1 p2 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"EverParse3d.Prelude.parser",
"EverParse3d.Kinds.weak_kind",
"LowParse.Spec.Combinators.nondep_then",
"Prims.op_BarBar",
"EverParse3d.Kinds.and_then_kind",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_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)) | [] | EverParse3d.Prelude.parse_pair | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p1: EverParse3d.Prelude.parser k1 t1 -> p2: EverParse3d.Prelude.parser k2 t2
-> EverParse3d.Prelude.parser (EverParse3d.Kinds.and_then_kind k1 k2) (t1 * t2) | {
"end_col": 25,
"end_line": 64,
"start_col": 4,
"start_line": 64
} |
Prims.Tot | val parse____UINT64 : parser kind____UINT64 ___UINT64 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT64 = LowParse.Spec.Int.parse_u64_le | val parse____UINT64 : parser kind____UINT64 ___UINT64
let parse____UINT64 = | false | null | false | LowParse.Spec.Int.parse_u64_le | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Int.parse_u64_le"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64
/// UInt16
let parse____UINT16 = LowParse.Spec.BoundedInt.parse_u16_le
let read____UINT16 = LowParse.Low.BoundedInt.read_u16_le
/// UInt32
let parse____UINT32 = LowParse.Spec.BoundedInt.parse_u32_le
let read____UINT32 = LowParse.Low.BoundedInt.read_u32_le | false | false | EverParse3d.Prelude.fst | {
"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____UINT64 : parser kind____UINT64 ___UINT64 | [] | EverParse3d.Prelude.parse____UINT64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT64 EverParse3d.Prelude.___UINT64 | {
"end_col": 52,
"end_line": 310,
"start_col": 22,
"start_line": 310
} |
Prims.Tot | val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT32BE = LowParse.Spec.Int.parse_u32 | val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE
let parse____UINT32BE = | false | null | false | LowParse.Spec.Int.parse_u32 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Int.parse_u32"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16 | false | false | EverParse3d.Prelude.fst | {
"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____UINT32BE : parser kind____UINT32BE ___UINT32BE | [] | EverParse3d.Prelude.parse____UINT32BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT32BE EverParse3d.Prelude.___UINT32BE | {
"end_col": 51,
"end_line": 292,
"start_col": 24,
"start_line": 292
} |
Prims.Tot | val cond_string_up_to (#t: eqtype) (terminator x: t) : Tot bool | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator | val cond_string_up_to (#t: eqtype) (terminator x: t) : Tot bool
let cond_string_up_to (#t: eqtype) (terminator x: t) : Tot bool = | false | null | false | x = terminator | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.op_Equality",
"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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t) | false | false | EverParse3d.Prelude.fst | {
"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 cond_string_up_to (#t: eqtype) (terminator x: t) : Tot bool | [] | EverParse3d.Prelude.cond_string_up_to | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | terminator: t -> x: t -> Prims.bool | {
"end_col": 16,
"end_line": 254,
"start_col": 2,
"start_line": 254
} |
Prims.Tot | val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT8BE = LowParse.Spec.Int.parse_u8 | val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE
let parse____UINT8BE = | false | null | false | LowParse.Spec.Int.parse_u8 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Int.parse_u8"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8 | false | false | EverParse3d.Prelude.fst | {
"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____UINT8BE : parser kind____UINT8BE ___UINT8BE | [] | EverParse3d.Prelude.parse____UINT8BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT8BE EverParse3d.Prelude.___UINT8BE | {
"end_col": 49,
"end_line": 284,
"start_col": 23,
"start_line": 284
} |
Prims.Tot | val read____UINT16BE : reader parse____UINT16BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT16BE = LowParse.Low.Int.read_u16 | val read____UINT16BE : reader parse____UINT16BE
let read____UINT16BE = | false | null | false | LowParse.Low.Int.read_u16 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Int.read_u16"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT16BE : reader parse____UINT16BE | [] | EverParse3d.Prelude.read____UINT16BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT16BE | {
"end_col": 48,
"end_line": 289,
"start_col": 23,
"start_line": 289
} |
Prims.Tot | val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 reader p = LPLC.leaf_reader p | val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1
let reader p = | false | null | false | LPLC.leaf_reader p | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"EverParse3d.Prelude.parser",
"LowParse.Low.Base.leaf_reader"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
//////////////////////////////////////////////////////////////////////////////// | false | false | EverParse3d.Prelude.fst | {
"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 reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 | [] | EverParse3d.Prelude.reader | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p: EverParse3d.Prelude.parser k t -> Type | {
"end_col": 33,
"end_line": 156,
"start_col": 15,
"start_line": 156
} |
Prims.Tot | val read____UINT16 : reader parse____UINT16 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT16 = LowParse.Low.BoundedInt.read_u16_le | val read____UINT16 : reader parse____UINT16
let read____UINT16 = | false | null | false | LowParse.Low.BoundedInt.read_u16_le | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.BoundedInt.read_u16_le"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64
/// UInt16 | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT16 : reader parse____UINT16 | [] | EverParse3d.Prelude.read____UINT16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT16 | {
"end_col": 56,
"end_line": 302,
"start_col": 21,
"start_line": 302
} |
Prims.Tot | val read____UINT64 : reader parse____UINT64 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT64 = LowParse.Low.Int.read_u64_le | val read____UINT64 : reader parse____UINT64
let read____UINT64 = | false | null | false | LowParse.Low.Int.read_u64_le | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Int.read_u64_le"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64
/// UInt16
let parse____UINT16 = LowParse.Spec.BoundedInt.parse_u16_le
let read____UINT16 = LowParse.Low.BoundedInt.read_u16_le
/// UInt32
let parse____UINT32 = LowParse.Spec.BoundedInt.parse_u32_le
let read____UINT32 = LowParse.Low.BoundedInt.read_u32_le
/// UInt64 | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT64 : reader parse____UINT64 | [] | EverParse3d.Prelude.read____UINT64 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT64 | {
"end_col": 49,
"end_line": 311,
"start_col": 21,
"start_line": 311
} |
Prims.Tot | val all_bytes: Type0 | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 all_bytes = Seq.seq LP.byte | val all_bytes: Type0
let all_bytes = | false | null | false | Seq.seq LP.byte | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist | false | true | EverParse3d.Prelude.fst | {
"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 all_bytes: Type0 | [] | EverParse3d.Prelude.all_bytes | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Type0 | {
"end_col": 31,
"end_line": 112,
"start_col": 16,
"start_line": 112
} |
Prims.Tot | val t_exact (n:U32.t) (t:Type u#r) : Type u#r | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 t_exact (n:U32.t) (t:Type) = t | val t_exact (n:U32.t) (t:Type u#r) : Type u#r
let t_exact (n: U32.t) (t: Type) = | false | null | false | t | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most | false | true | EverParse3d.Prelude.fst | {
"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 t_exact (n:U32.t) (t:Type u#r) : Type u#r | [] | EverParse3d.Prelude.t_exact | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> t: Type -> Type | {
"end_col": 34,
"end_line": 137,
"start_col": 33,
"start_line": 137
} |
Prims.Tot | val cstring
(t: eqtype)
(terminator: t)
: Tot Type0 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator) | val cstring
(t: eqtype)
(terminator: t)
: Tot Type0
let cstring (t: eqtype) (terminator: t) : Tot Type0 = | false | null | false | LUT.parse_list_up_to_t (cond_string_up_to terminator) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.eqtype",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"EverParse3d.Prelude.cond_string_up_to"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t) | false | false | EverParse3d.Prelude.fst | {
"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 cstring
(t: eqtype)
(terminator: t)
: Tot Type0 | [] | EverParse3d.Prelude.cstring | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | t: Prims.eqtype -> terminator: t -> Type0 | {
"end_col": 55,
"end_line": 260,
"start_col": 2,
"start_line": 260
} |
Prims.Tot | val parse____UINT8 : parser kind____UINT8 ___UINT8 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT8 = LowParse.Spec.Int.parse_u8 | val parse____UINT8 : parser kind____UINT8 ___UINT8
let parse____UINT8 = | false | null | false | LowParse.Spec.Int.parse_u8 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Int.parse_u8"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
//////////////////////////////////////////////////////////////////////////////// | false | false | EverParse3d.Prelude.fst | {
"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____UINT8 : parser kind____UINT8 ___UINT8 | [] | EverParse3d.Prelude.parse____UINT8 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT8 EverParse3d.Prelude.___UINT8 | {
"end_col": 47,
"end_line": 280,
"start_col": 21,
"start_line": 280
} |
Prims.Tot | val parse____UINT32 : parser kind____UINT32 ___UINT32 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT32 = LowParse.Spec.BoundedInt.parse_u32_le | val parse____UINT32 : parser kind____UINT32 ___UINT32
let parse____UINT32 = | false | null | false | LowParse.Spec.BoundedInt.parse_u32_le | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.parse_u32_le"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64
/// UInt16
let parse____UINT16 = LowParse.Spec.BoundedInt.parse_u16_le
let read____UINT16 = LowParse.Low.BoundedInt.read_u16_le | false | false | EverParse3d.Prelude.fst | {
"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____UINT32 : parser kind____UINT32 ___UINT32 | [] | EverParse3d.Prelude.parse____UINT32 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT32 EverParse3d.Prelude.___UINT32 | {
"end_col": 59,
"end_line": 305,
"start_col": 22,
"start_line": 305
} |
Prims.Tot | val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT64BE = LowParse.Spec.Int.parse_u64 | val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE
let parse____UINT64BE = | false | null | false | LowParse.Spec.Int.parse_u64 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Int.parse_u64"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32 | false | false | EverParse3d.Prelude.fst | {
"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____UINT64BE : parser kind____UINT64BE ___UINT64BE | [] | EverParse3d.Prelude.parse____UINT64BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT64BE EverParse3d.Prelude.___UINT64BE | {
"end_col": 51,
"end_line": 296,
"start_col": 24,
"start_line": 296
} |
Prims.Tot | val read____UINT64BE : reader parse____UINT64BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT64BE = LowParse.Low.Int.read_u64 | val read____UINT64BE : reader parse____UINT64BE
let read____UINT64BE = | false | null | false | LowParse.Low.Int.read_u64 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Int.read_u64"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT64BE : reader parse____UINT64BE | [] | EverParse3d.Prelude.read____UINT64BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT64BE | {
"end_col": 48,
"end_line": 297,
"start_col": 23,
"start_line": 297
} |
Prims.Tot | 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) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read_filter p32 f
= LPLC.read_filter p32 f | 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)
let read_filter p32 f = | false | null | false | LPLC.read_filter p32 f | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"EverParse3d.Prelude.parser",
"EverParse3d.Prelude.reader",
"LowParse.Low.Combinators.read_filter",
"EverParse3d.Kinds.filter_kind",
"EverParse3d.Prelude.refine",
"EverParse3d.Prelude.parse_filter"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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 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) | [] | EverParse3d.Prelude.read_filter | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p32: EverParse3d.Prelude.reader p -> f: (_: t -> Prims.bool)
-> EverParse3d.Prelude.reader (EverParse3d.Prelude.parse_filter p f) | {
"end_col": 28,
"end_line": 160,
"start_col": 6,
"start_line": 160
} |
Prims.Tot | val parse_all_zeros: parser kind_all_zeros all_zeros | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero) | val parse_all_zeros: parser kind_all_zeros all_zeros
let parse_all_zeros = | false | null | false | LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8
is_zero) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.List.parse_list",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.Int.parse_u8_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"FStar.UInt8.t",
"EverParse3d.Prelude.is_zero",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.Int.parse_u8"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy | false | false | EverParse3d.Prelude.fst | {
"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_all_zeros: parser kind_all_zeros all_zeros | [] | EverParse3d.Prelude.parse_all_zeros | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind_all_zeros EverParse3d.Prelude.all_zeros | {
"end_col": 127,
"end_line": 272,
"start_col": 22,
"start_line": 272
} |
Prims.Tot | val read____UINT8BE : reader parse____UINT8BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT8BE = LowParse.Low.Int.read_u8 | val read____UINT8BE : reader parse____UINT8BE
let read____UINT8BE = | false | null | false | LowParse.Low.Int.read_u8 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Int.read_u8"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT8BE : reader parse____UINT8BE | [] | EverParse3d.Prelude.read____UINT8BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT8BE | {
"end_col": 46,
"end_line": 285,
"start_col": 22,
"start_line": 285
} |
Prims.Tot | val read____UINT32BE : reader parse____UINT32BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT32BE = LowParse.Low.Int.read_u32 | val read____UINT32BE : reader parse____UINT32BE
let read____UINT32BE = | false | null | false | LowParse.Low.Int.read_u32 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Int.read_u32"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT32BE : reader parse____UINT32BE | [] | EverParse3d.Prelude.read____UINT32BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT32BE | {
"end_col": 48,
"end_line": 293,
"start_col": 23,
"start_line": 293
} |
Prims.Tot | val read_unit
: reader (parse_ret ()) | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read_unit
: LPL.leaf_reader (parse_ret ())
= LPLC.read_ret () | val read_unit
: reader (parse_ret ())
let read_unit:LPL.leaf_reader (parse_ret ()) = | false | null | false | LPLC.read_ret () | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Combinators.read_ret",
"Prims.unit",
"LowParse.Low.Base.leaf_reader",
"EverParse3d.Kinds.ret_kind",
"EverParse3d.Prelude.parse_ret"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64
/// UInt16
let parse____UINT16 = LowParse.Spec.BoundedInt.parse_u16_le
let read____UINT16 = LowParse.Low.BoundedInt.read_u16_le
/// UInt32
let parse____UINT32 = LowParse.Spec.BoundedInt.parse_u32_le
let read____UINT32 = LowParse.Low.BoundedInt.read_u32_le
/// UInt64
let parse____UINT64 = LowParse.Spec.Int.parse_u64_le
let read____UINT64 = LowParse.Low.Int.read_u64_le
inline_for_extraction noextract
let read_unit | false | false | EverParse3d.Prelude.fst | {
"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 read_unit
: reader (parse_ret ()) | [] | EverParse3d.Prelude.read_unit | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader (EverParse3d.Prelude.parse_ret ()) | {
"end_col": 20,
"end_line": 316,
"start_col": 4,
"start_line": 316
} |
Prims.Tot | val is_zero (x: FStar.UInt8.t) : Tot bool | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy | val is_zero (x: FStar.UInt8.t) : Tot bool
let is_zero (x: FStar.UInt8.t) : Tot bool = | false | null | false | x = 0uy | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.UInt8.t",
"Prims.op_Equality",
"FStar.UInt8.__uint_to_t",
"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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ())) | false | true | EverParse3d.Prelude.fst | {
"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 is_zero (x: FStar.UInt8.t) : Tot bool | [] | EverParse3d.Prelude.is_zero | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | x: FStar.UInt8.t -> Prims.bool | {
"end_col": 51,
"end_line": 269,
"start_col": 44,
"start_line": 269
} |
Prims.Tot | val all_zeros: Type0 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero) | val all_zeros: Type0
let all_zeros = | false | null | false | list (LowParse.Spec.Combinators.parse_filter_refine is_zero) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.list",
"LowParse.Spec.Combinators.parse_filter_refine",
"FStar.UInt8.t",
"EverParse3d.Prelude.is_zero"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy | false | true | EverParse3d.Prelude.fst | {
"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 all_zeros: Type0 | [] | EverParse3d.Prelude.all_zeros | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | Type0 | {
"end_col": 76,
"end_line": 271,
"start_col": 16,
"start_line": 271
} |
Prims.Tot | val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT16BE = LowParse.Spec.Int.parse_u16 | val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE
let parse____UINT16BE = | false | null | false | LowParse.Spec.Int.parse_u16 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Int.parse_u16"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8 | false | false | EverParse3d.Prelude.fst | {
"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____UINT16BE : parser kind____UINT16BE ___UINT16BE | [] | EverParse3d.Prelude.parse____UINT16BE | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT16BE EverParse3d.Prelude.___UINT16BE | {
"end_col": 51,
"end_line": 288,
"start_col": 24,
"start_line": 288
} |
Prims.Tot | val parse____UINT16 : parser kind____UINT16 ___UINT16 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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____UINT16 = LowParse.Spec.BoundedInt.parse_u16_le | val parse____UINT16 : parser kind____UINT16 ___UINT16
let parse____UINT16 = | false | null | false | LowParse.Spec.BoundedInt.parse_u16_le | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.parse_u16_le"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8
let parse____UINT8 = LowParse.Spec.Int.parse_u8
let read____UINT8 = LowParse.Low.Int.read_u8
/// UINT8BE
let parse____UINT8BE = LowParse.Spec.Int.parse_u8
let read____UINT8BE = LowParse.Low.Int.read_u8
/// UInt16BE
let parse____UINT16BE = LowParse.Spec.Int.parse_u16
let read____UINT16BE = LowParse.Low.Int.read_u16
/// UInt32BE
let parse____UINT32BE = LowParse.Spec.Int.parse_u32
let read____UINT32BE = LowParse.Low.Int.read_u32
/// UInt64BE
let parse____UINT64BE = LowParse.Spec.Int.parse_u64
let read____UINT64BE = LowParse.Low.Int.read_u64 | false | false | EverParse3d.Prelude.fst | {
"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____UINT16 : parser kind____UINT16 ___UINT16 | [] | EverParse3d.Prelude.parse____UINT16 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind____UINT16 EverParse3d.Prelude.___UINT16 | {
"end_col": 59,
"end_line": 301,
"start_col": 22,
"start_line": 301
} |
Prims.Tot | [
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k' | let is_weaker_than #nz1 #wk1 (k: parser_kind nz1 wk1) #nz2 #wk2 (k': parser_kind nz2 wk2) = | false | null | false | k `LP.is_weaker_than` k' | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"LowParse.Spec.Base.is_weaker_than"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t | false | false | EverParse3d.Prelude.fst | {
"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 is_weaker_than : k: EverParse3d.Kinds.parser_kind nz1 wk1 -> k': EverParse3d.Kinds.parser_kind nz2 wk2 -> Type0 | [] | EverParse3d.Prelude.is_weaker_than | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: EverParse3d.Kinds.parser_kind nz1 wk1 -> k': EverParse3d.Kinds.parser_kind nz2 wk2 -> Type0 | {
"end_col": 80,
"end_line": 34,
"start_col": 56,
"start_line": 34
} |
|
Prims.Tot | val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v | val parse_ret (#t:Type) (v:t)
: Tot (parser ret_kind t)
let parse_ret #t (v: t) : Tot (parser ret_kind t) = | false | null | false | LPC.parse_ret #t v | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Spec.Combinators.parse_ret",
"EverParse3d.Prelude.parser",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"EverParse3d.Kinds.ret_kind"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t) | false | false | EverParse3d.Prelude.fst | {
"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_ret (#t:Type) (v:t)
: Tot (parser ret_kind t) | [] | EverParse3d.Prelude.parse_ret | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | v: t -> EverParse3d.Prelude.parser EverParse3d.Kinds.ret_kind t | {
"end_col": 22,
"end_line": 54,
"start_col": 4,
"start_line": 54
} |
Prims.Tot | val read____UINT8 : reader parse____UINT8 | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read____UINT8 = LowParse.Low.Int.read_u8 | val read____UINT8 : reader parse____UINT8
let read____UINT8 = | false | null | false | LowParse.Low.Int.read_u8 | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Low.Int.read_u8"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ()))
inline_for_extraction noextract
let is_zero (x: FStar.UInt8.t) : Tot bool = x = 0uy
let all_zeros = list (LowParse.Spec.Combinators.parse_filter_refine is_zero)
let parse_all_zeros = LowParse.Spec.List.parse_list (LowParse.Spec.Combinators.parse_filter LowParse.Spec.Int.parse_u8 is_zero)
////////////////////////////////////////////////////////////////////////////////
// Base types
////////////////////////////////////////////////////////////////////////////////
/// UINT8 | false | false | EverParse3d.Prelude.fst | {
"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 read____UINT8 : reader parse____UINT8 | [] | EverParse3d.Prelude.read____UINT8 | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader EverParse3d.Prelude.parse____UINT8 | {
"end_col": 44,
"end_line": 281,
"start_col": 20,
"start_line": 281
} |
Prims.Tot | val parse_all_bytes':LP.bare_parser all_bytes | [
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input)) | val parse_all_bytes':LP.bare_parser all_bytes
let parse_all_bytes':LP.bare_parser all_bytes = | false | null | false | fun input -> Some (input, (Seq.length input <: LP.consumed_length input)) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Bytes.bytes",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.tuple2",
"EverParse3d.Prelude.all_bytes",
"LowParse.Spec.Base.consumed_length",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.Pervasives.Native.option"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes' | false | true | EverParse3d.Prelude.fst | {
"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_all_bytes':LP.bare_parser all_bytes | [] | EverParse3d.Prelude.parse_all_bytes' | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Base.bare_parser EverParse3d.Prelude.all_bytes | {
"end_col": 77,
"end_line": 115,
"start_col": 4,
"start_line": 115
} |
Prims.Tot | 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) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p | 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)
let parse_weaken_left #nz #wk #k p k' = | false | null | false | LP.weaken (glb k' k) p | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"LowParse.Spec.Base.weaken",
"EverParse3d.Kinds.glb",
"Prims.op_AmpAmp",
"EverParse3d.Kinds.weak_kind_glb"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_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) | [] | EverParse3d.Prelude.parse_weaken_left | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p: EverParse3d.Prelude.parser k t -> k': EverParse3d.Kinds.parser_kind nz' wk'
-> EverParse3d.Prelude.parser (EverParse3d.Kinds.glb k' k) t | {
"end_col": 26,
"end_line": 83,
"start_col": 4,
"start_line": 83
} |
Prims.Tot | 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) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p | 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)
let parse_weaken_right #nz #wk #k p k' = | false | null | false | LP.weaken (glb k k') p | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"LowParse.Spec.Base.weaken",
"EverParse3d.Kinds.glb",
"Prims.op_AmpAmp",
"EverParse3d.Kinds.weak_kind_glb"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_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) | [] | EverParse3d.Prelude.parse_weaken_right | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p: EverParse3d.Prelude.parser k t -> k': EverParse3d.Kinds.parser_kind nz' wk'
-> EverParse3d.Prelude.parser (EverParse3d.Kinds.glb k k') t | {
"end_col": 26,
"end_line": 88,
"start_col": 4,
"start_line": 88
} |
Prims.Tot | val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t)) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist | val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t))
let parse_nlist n #wk #k #t p = | false | null | false | let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken #false
#WeakKindStrongPrefix
#(parse_fldata_kind (U32.v n) parse_list_kind)
#(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false
kind_nlist | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"EverParse3d.Prelude.parse_weaken",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"LowParse.Spec.FLData.parse_fldata_kind",
"FStar.UInt32.v",
"LowParse.Spec.List.parse_list_kind",
"Prims.list",
"LowParse.Spec.FLData.parse_fldata",
"LowParse.Spec.List.parse_list",
"EverParse3d.Kinds.kind_nlist",
"EverParse3d.Prelude.nlist"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t)
: Tot (parser kind_nlist (nlist n t)) | [] | EverParse3d.Prelude.parse_nlist | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t
-> EverParse3d.Prelude.parser EverParse3d.Kinds.kind_nlist (EverParse3d.Prelude.nlist n t) | {
"end_col": 29,
"end_line": 110,
"start_col": 4,
"start_line": 105
} |
Prims.Tot | val parse_weaken
(#nz #wk: _)
(#k: parser_kind nz wk)
(#t: _)
(p: parser k t)
(#nz' #wk': _)
(k': parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t) | [
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p | val parse_weaken
(#nz #wk: _)
(#k: parser_kind nz wk)
(#t: _)
(p: parser k t)
(#nz' #wk': _)
(k': parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
let parse_weaken
#nz
#wk
(#k: parser_kind nz wk)
#t
(p: parser k t)
#nz'
#wk'
(k': parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t) = | false | null | false | LP.weaken k' p | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"EverParse3d.Prelude.is_weaker_than",
"LowParse.Spec.Base.weaken"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k}) | false | false | EverParse3d.Prelude.fst | {
"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_weaken
(#nz #wk: _)
(#k: parser_kind nz wk)
(#t: _)
(p: parser k t)
(#nz' #wk': _)
(k': parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t) | [] | EverParse3d.Prelude.parse_weaken | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
p: EverParse3d.Prelude.parser k t ->
k': EverParse3d.Kinds.parser_kind nz' wk' {EverParse3d.Prelude.is_weaker_than k' k}
-> EverParse3d.Prelude.parser k' t | {
"end_col": 18,
"end_line": 78,
"start_col": 4,
"start_line": 78
} |
Prims.Tot | val read_impos : reader (parse_impos()) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim () | val read_impos : reader (parse_impos())
let read_impos:reader (parse_impos ()) = | false | null | false | fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get () in
assert (LPLC.valid (parse_impos ()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos ()) h sl pos;
false_elim () | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Pervasives.false_elim",
"Prims.l_False",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_equiv",
"EverParse3d.Kinds.impos_kind",
"EverParse3d.Prelude.parse_impos",
"Prims._assert",
"LowParse.Low.Base.Spec.valid",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"EverParse3d.Prelude.reader"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f | false | false | EverParse3d.Prelude.fst | {
"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 read_impos : reader (parse_impos()) | [] | EverParse3d.Prelude.read_impos | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.reader (EverParse3d.Prelude.parse_impos ()) | {
"end_col": 17,
"end_line": 167,
"start_col": 2,
"start_line": 163
} |
Prims.Tot | 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)) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact | 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))
let parse_t_exact n #nz #wk #k #t p = | false | null | false | let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken #false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata p (U32.v n))
#false
kind_t_exact | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"EverParse3d.Prelude.parse_weaken",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"LowParse.Spec.FLData.parse_fldata_kind",
"FStar.UInt32.v",
"LowParse.Spec.FLData.parse_fldata",
"EverParse3d.Kinds.kind_t_exact",
"EverParse3d.Prelude.t_exact"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_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)) | [] | EverParse3d.Prelude.parse_t_exact | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t
-> EverParse3d.Prelude.parser EverParse3d.Kinds.kind_t_exact (EverParse3d.Prelude.t_exact n t) | {
"end_col": 24,
"end_line": 149,
"start_col": 4,
"start_line": 140
} |
Prims.Tot | val parse_all_bytes: parser kind_all_bytes all_bytes | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes' | val parse_all_bytes: parser kind_all_bytes all_bytes
let parse_all_bytes = | false | null | false | LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes' | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"EverParse3d.Prelude.parse_all_bytes'",
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"EverParse3d.Prelude.all_bytes",
"EverParse3d.Kinds.kind_all_bytes"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input)) | false | false | EverParse3d.Prelude.fst | {
"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_all_bytes: parser kind_all_bytes all_bytes | [] | EverParse3d.Prelude.parse_all_bytes | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | EverParse3d.Prelude.parser EverParse3d.Kinds.kind_all_bytes EverParse3d.Prelude.all_bytes | {
"end_col": 18,
"end_line": 118,
"start_col": 2,
"start_line": 117
} |
Prims.Tot | val parse_impos (_:unit)
: parser impos_kind False | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p | val parse_impos (_:unit)
: parser impos_kind False
let parse_impos () : parser impos_kind False = | false | null | false | let p:LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"Prims.l_False",
"EverParse3d.Kinds.impos_kind",
"LowParse.Spec.Base.bare_parser",
"LowParse.Bytes.bytes",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"FStar.Pervasives.Native.option",
"EverParse3d.Prelude.parser",
"EverParse3d.Kinds.WeakKindStrongPrefix"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos () | false | false | EverParse3d.Prelude.fst | {
"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_impos (_:unit)
: parser impos_kind False | [] | EverParse3d.Prelude.parse_impos | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | _: Prims.unit -> EverParse3d.Prelude.parser EverParse3d.Kinds.impos_kind Prims.l_False | {
"end_col": 5,
"end_line": 96,
"start_col": 3,
"start_line": 94
} |
Prims.Tot | 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)) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most | 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))
let parse_t_at_most n #nz #wk #k #t p = | false | null | false | let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken #false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata (LPC.nondep_then p parse_all_bytes) (U32.v n))
#false
kind_t_at_most | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"FStar.UInt32.t",
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"EverParse3d.Prelude.parse_weaken",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"LowParse.Spec.FLData.parse_fldata_kind",
"FStar.UInt32.v",
"LowParse.Spec.Combinators.and_then_kind",
"EverParse3d.Kinds.kind_all_bytes",
"FStar.Pervasives.Native.tuple2",
"EverParse3d.Prelude.all_bytes",
"LowParse.Spec.FLData.parse_fldata",
"LowParse.Spec.Combinators.nondep_then",
"EverParse3d.Prelude.parse_all_bytes",
"EverParse3d.Kinds.kind_t_at_most",
"EverParse3d.Prelude.t_at_most"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract | false | false | EverParse3d.Prelude.fst | {
"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_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)) | [] | EverParse3d.Prelude.parse_t_at_most | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t
-> EverParse3d.Prelude.parser EverParse3d.Kinds.kind_t_at_most (EverParse3d.Prelude.t_at_most n t) | {
"end_col": 26,
"end_line": 134,
"start_col": 4,
"start_line": 125
} |
Prims.Tot | val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator)) | [
{
"abbrev": true,
"full_module": "LowParse.Spec.ListUpTo",
"short_module": "LUT"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_string
#k #t p terminator
=
LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind (LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ())) | val parse_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator))
let parse_string #k #t p terminator = | false | null | false | LowParse.Spec.Base.parser_kind_prop_equiv k p;
LP.weaken parse_string_kind
(LUT.parse_list_up_to (cond_string_up_to terminator) p (fun _ _ _ -> ())) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"Prims.eqtype",
"EverParse3d.Prelude.parser",
"LowParse.Spec.Base.weaken",
"EverParse3d.Kinds.parse_string_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"EverParse3d.Prelude.cond_string_up_to",
"LowParse.Spec.ListUpTo.parse_list_up_to",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.consumed_length",
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"EverParse3d.Prelude.cstring"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
)
module LUT = LowParse.Spec.ListUpTo
inline_for_extraction
noextract
let cond_string_up_to
(#t: eqtype)
(terminator: t)
(x: t)
: Tot bool
= x = terminator
let cstring
(t: eqtype)
(terminator: t)
: Tot Type0
= LUT.parse_list_up_to_t (cond_string_up_to terminator)
let parse_string
#k #t p terminator | false | false | EverParse3d.Prelude.fst | {
"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_string
(#k: parser_kind true WeakKindStrongPrefix)
(#t: eqtype)
(p: parser k t)
(terminator: t)
: Tot (parser parse_string_kind (cstring t terminator)) | [] | EverParse3d.Prelude.parse_string | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | p: EverParse3d.Prelude.parser k t -> terminator: t
-> EverParse3d.Prelude.parser EverParse3d.Kinds.parse_string_kind
(EverParse3d.Prelude.cstring t terminator) | {
"end_col": 103,
"end_line": 266,
"start_col": 2,
"start_line": 265
} |
FStar.Pervasives.Lemma | val parse_nlist_total_fixed_size_aux
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: _)
(p: parser k t)
(x: LP.bytes)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n)) (ensures (Some? (LP.parse (parse_nlist n p) x))) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p) | val parse_nlist_total_fixed_size_aux
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: _)
(p: parser k t)
(x: LP.bytes)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n)) (ensures (Some? (LP.parse (parse_nlist n p) x)))
let parse_nlist_total_fixed_size_aux
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
#t
(p: parser k t)
(x: LP.bytes)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n)) (ensures (Some? (LP.parse (parse_nlist n p) x))) = | false | null | true | let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"LowParse.Bytes.bytes",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"Prims.list",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"Prims.unit",
"LowParse.Spec.List.parse_list_total_constant_size",
"FStar.Math.Lemmas.nat_over_pos_is_nat",
"FStar.UInt32.v",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"FStar.Math.Lemmas.lemma_div_exact",
"Prims.int",
"Prims.op_Division",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"FStar.Seq.Base.slice",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"Prims.op_Modulus",
"LowParse.Spec.Base.parser_kind_metadata_some",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata",
"LowParse.Spec.Base.ParserKindMetadataTotal",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.length",
"Prims.squash",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"EverParse3d.Prelude.nlist",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"EverParse3d.Prelude.parse_nlist",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x) | false | false | EverParse3d.Prelude.fst | {
"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_nlist_total_fixed_size_aux
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: _)
(p: parser k t)
(x: LP.bytes)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n)) (ensures (Some? (LP.parse (parse_nlist n p) x))) | [] | EverParse3d.Prelude.parse_nlist_total_fixed_size_aux | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t -> x: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(requires
Mkparser_kind'?.parser_kind_subkind k ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
Mkparser_kind'?.parser_kind_high k ==
FStar.Pervasives.Native.Some (Mkparser_kind'?.parser_kind_low k) /\
FStar.UInt32.v n % Mkparser_kind'?.parser_kind_low k == 0 /\
Mkparser_kind'?.parser_kind_metadata k ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserKindMetadataTotal /\
FStar.Seq.Base.length x >= FStar.UInt32.v n)
(ensures Some? (LowParse.Spec.Base.parse (EverParse3d.Prelude.parse_nlist n p) x)) | {
"end_col": 96,
"end_line": 202,
"start_col": 1,
"start_line": 197
} |
Prims.Tot | 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)) | [
{
"abbrev": true,
"full_module": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_ite e p1 p2
= if e then p1 () else p2 () | 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))
let parse_ite e p1 p2 = | false | null | false | if e then p1 () else p2 () | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"total"
] | [
"Prims.bool",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"Prims.squash",
"Prims.b2t",
"Prims.op_Negation",
"EverParse3d.Prelude.parser",
"EverParse3d.Prelude.t_ite"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p | false | false | EverParse3d.Prelude.fst | {
"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_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)) | [] | EverParse3d.Prelude.parse_ite | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
e: Prims.bool ->
p1: (_: Prims.squash e -> EverParse3d.Prelude.parser k (a ())) ->
p2: (_: Prims.squash (Prims.op_Negation e) -> EverParse3d.Prelude.parser k (b ()))
-> EverParse3d.Prelude.parser k (EverParse3d.Prelude.t_ite e a b) | {
"end_col": 30,
"end_line": 99,
"start_col": 4,
"start_line": 99
} |
Prims.Pure | val validate_nlist_total_constant_size_mod_ok
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: Type)
(p: parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0))
(ensures (fun _ -> True)) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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 validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True))
=
(fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@inline_let]
let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) h sl (LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (FStar.Int.Cast.uint32_to_uint64 n) () sl len pos
) | val validate_nlist_total_constant_size_mod_ok
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: Type)
(p: parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0))
(ensures (fun _ -> True))
let validate_nlist_total_constant_size_mod_ok
(n: U32.t)
#wk
(#k: parser_kind true wk)
(#t: Type)
(p: parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0))
(ensures (fun _ -> True)) = | false | null | false | (fun #rrel #rel sl len pos ->
let h = FStar.HyperStack.ST.get () in
[@@ inline_let ]let _ =
parse_nlist_total_fixed_size_kind_correct n p;
LPL.valid_facts (parse_nlist n p) h sl (LPL.uint64_to_uint32 pos);
LPL.valid_facts (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n))
(parse_nlist n p))
h
sl
(LPL.uint64_to_uint32 pos)
in
LPL.validate_total_constant_size_no_read (LP.strengthen (LP.total_constant_size_parser_kind (U32.v
n))
(parse_nlist n p))
(FStar.Int.Cast.uint32_to_uint64 n)
()
sl
len
pos) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [] | [
"FStar.UInt32.t",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"FStar.Ghost.erased",
"LowParse.Slice.slice",
"Prims.eq2",
"LowParse.Slice.__proj__Mkslice__item__len",
"FStar.Ghost.reveal",
"FStar.UInt64.t",
"LowParse.Low.Base.validate_total_constant_size_no_read",
"LowParse.Spec.Base.total_constant_size_parser_kind",
"FStar.UInt32.v",
"EverParse3d.Prelude.nlist",
"LowParse.Spec.Base.strengthen",
"EverParse3d.Prelude.parse_nlist",
"FStar.Int.Cast.uint32_to_uint64",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"EverParse3d.Kinds.kind_nlist",
"EverParse3d.Prelude.parse_nlist_total_fixed_size_kind_correct",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"EverParse3d.Prelude.validator_no_read",
"EverParse3d.Kinds.WeakKindStrongPrefix",
"Prims.l_and",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.parser_kind_metadata_some",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata",
"LowParse.Spec.Base.ParserKindMetadataTotal",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.int",
"Prims.op_Modulus",
"Prims.l_True"
] | [] | (*
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
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p))
inline_for_extraction noextract
let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0
))
(ensures (fun _ -> True)) | false | false | EverParse3d.Prelude.fst | {
"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 validate_nlist_total_constant_size_mod_ok
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: Type)
(p: parser k t)
: Pure (validator_no_read (parse_nlist n p))
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\
U32.v n % k.LP.parser_kind_low == 0))
(ensures (fun _ -> True)) | [] | EverParse3d.Prelude.validate_nlist_total_constant_size_mod_ok | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t
-> Prims.Pure (EverParse3d.Prelude.validator_no_read (EverParse3d.Prelude.parse_nlist n p)) | {
"end_col": 7,
"end_line": 243,
"start_col": 6,
"start_line": 234
} |
FStar.Pervasives.Lemma | val parse_nlist_total_fixed_size_kind_correct
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: _)
(p: parser k t)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures
(LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p))) | [
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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": "LowParse.Low.Combinators",
"short_module": "LPLC"
},
{
"abbrev": true,
"full_module": "LowParse.Low.Base",
"short_module": "LPL"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Combinators",
"short_module": "LPC"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Base",
"short_module": "LP"
},
{
"abbrev": true,
"full_module": "LowParse.BitFields",
"short_module": "BF"
},
{
"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_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)
))
= LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) (parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p)) | val parse_nlist_total_fixed_size_kind_correct
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: _)
(p: parser k t)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures
(LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)))
let parse_nlist_total_fixed_size_kind_correct
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
#t
(p: parser k t)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures
(LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p))) = | false | null | true | LP.parser_kind_prop_equiv (LowParse.Spec.FLData.parse_fldata_kind (U32.v n)
LowParse.Spec.List.parse_list_kind)
(parse_nlist n p);
LP.parser_kind_prop_equiv (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p);
Classical.forall_intro (Classical.move_requires (parse_nlist_total_fixed_size_aux n p)) | {
"checked_file": "EverParse3d.Prelude.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Spec.List.fsti.checked",
"LowParse.Spec.Int.fsti.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Low.Int.fsti.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.BoundedInt.fsti.checked",
"LowParse.Low.Base.Spec.fsti.checked",
"LowParse.Low.Base.fst.checked",
"LowParse.BitFields.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Bytes.fsti.checked",
"EverParse3d.Kinds.fst.checked"
],
"interface_file": true,
"source_file": "EverParse3d.Prelude.fst"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"EverParse3d.Kinds.weak_kind",
"EverParse3d.Kinds.parser_kind",
"EverParse3d.Prelude.parser",
"FStar.Classical.forall_intro",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"Prims.int",
"Prims.op_Modulus",
"FStar.UInt32.v",
"LowParse.Spec.Base.parser_kind_metadata_some",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata",
"LowParse.Spec.Base.ParserKindMetadataTotal",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"EverParse3d.Prelude.nlist",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"EverParse3d.Prelude.parse_nlist",
"FStar.Classical.move_requires",
"EverParse3d.Prelude.parse_nlist_total_fixed_size_aux",
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"LowParse.Spec.Base.total_constant_size_parser_kind",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.List.parse_list_kind",
"Prims.squash",
"LowParse.Spec.Base.parser_kind_prop",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2019 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module EverParse3d.Prelude
friend EverParse3d.Kinds
module BF = LowParse.BitFields
module LP = LowParse.Spec.Base
module LPC = LowParse.Spec.Combinators
module LPL = LowParse.Low.Base
module LPLC = LowParse.Low.Combinators
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
////////////////////////////////////////////////////////////////////////////////
// Parsers
////////////////////////////////////////////////////////////////////////////////
let parser k t = LP.parser k t
let is_weaker_than #nz1 #wk1 (k:parser_kind nz1 wk1)
#nz2 #wk2 (k':parser_kind nz2 wk2) = k `LP.is_weaker_than` k'
let is_weaker_than_refl #nz #wk (k:parser_kind nz wk)
: Lemma (ensures (is_weaker_than k k))
[SMTPat (is_weaker_than k k)]
= ()
let is_weaker_than_glb #nz1 #wk1 (k1:parser_kind nz1 wk1)
#nz2 #wk2 (k2:parser_kind nz2 wk2)
: Lemma (is_weaker_than (glb k1 k2) k1 /\
is_weaker_than (glb k1 k2) k2)
[SMTPatOr
[[SMTPat (is_weaker_than (glb k1 k2) k1)];
[SMTPat (is_weaker_than (glb k1 k2) k2)]]]
= ()
/// Parser: return
inline_for_extraction noextract
let parse_ret #t (v:t)
: Tot (parser ret_kind t)
= LPC.parse_ret #t v
/// Parser: bind
inline_for_extraction noextract
let parse_dep_pair p1 p2
= LPC.parse_dtuple2 p1 p2
/// Parser: sequencing
inline_for_extraction noextract
let parse_pair p1 p2
= LPC.nondep_then p1 p2
/// Parser: map
let injective_map a b = (a -> Tot b) //{LPC.synth_injective f}
inline_for_extraction noextract
let parse_filter p f
= LPC.parse_filter p f
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken #nz #wk (#k:parser_kind nz wk) #t (p:parser k t)
#nz' #wk' (k':parser_kind nz' wk' {k' `is_weaker_than` k})
: Tot (parser k' t)
= LP.weaken k' p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_left #nz #wk #k p k'
= LP.weaken (glb k' k) p
/// Parser: weakening kinds
inline_for_extraction noextract
let parse_weaken_right #nz #wk #k p k'
= LP.weaken (glb k k') p
/// Parser: unreachable, for default cases of exhaustive pattern matching
inline_for_extraction noextract
let parse_impos ()
: parser impos_kind False
= let p : LP.bare_parser False = fun b -> None in
LP.parser_kind_prop_equiv impos_kind p;
p
let parse_ite e p1 p2
= if e then p1 () else p2 ()
let nlist (n:U32.t) (t:Type) = list t
inline_for_extraction noextract
let parse_nlist n #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false #WeakKindStrongPrefix #(parse_fldata_kind (U32.v n) parse_list_kind) #(list t)
(LowParse.Spec.FLData.parse_fldata (LowParse.Spec.List.parse_list p) (U32.v n))
#false kind_nlist
let all_bytes = Seq.seq LP.byte
let parse_all_bytes'
: LP.bare_parser all_bytes
= fun input -> Some (input, (Seq.length input <: LP.consumed_length input))
let parse_all_bytes =
LP.parser_kind_prop_equiv kind_all_bytes parse_all_bytes';
parse_all_bytes'
////////////////////////////////////////////////////////////////////////////////
module B32 = FStar.Bytes
let t_at_most (n:U32.t) (t:Type) = t & all_bytes
inline_for_extraction noextract
let parse_t_at_most n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
(LPC.nondep_then p parse_all_bytes)
(U32.v n))
#false
kind_t_at_most
////////////////////////////////////////////////////////////////////////////////
let t_exact (n:U32.t) (t:Type) = t
inline_for_extraction noextract
let parse_t_exact n #nz #wk #k #t p
= let open LowParse.Spec.FLData in
let open LowParse.Spec.List in
parse_weaken
#false
#WeakKindStrongPrefix
(LowParse.Spec.FLData.parse_fldata
p
(U32.v n))
#false
kind_t_exact
////////////////////////////////////////////////////////////////////////////////
// Readers
////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let reader p = LPLC.leaf_reader p
inline_for_extraction noextract
let read_filter p32 f
= LPLC.read_filter p32 f
let read_impos : reader (parse_impos()) =
fun #rrel #rel sl pos ->
let h = FStar.HyperStack.ST.get() in
assert (LPLC.valid (parse_impos()) h sl pos);
LowParse.Low.Base.Spec.valid_equiv (parse_impos()) h sl pos;
false_elim ()
// ////////////////////////////////////////////////////////////////////////////////
// // Validators
// ////////////////////////////////////////////////////////////////////////////////
inline_for_extraction noextract
let validator #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator #k #t p
inline_for_extraction noextract
let validator_no_read #nz #wk (#k:parser_kind nz wk) (#t:Type) (p:parser k t)
: Type
= LPL.validator_no_read #k #t p
let parse_nlist_total_fixed_size_aux
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
(x: LP.bytes)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal /\
Seq.length x >= U32.v n
))
(ensures (
Some? (LP.parse (parse_nlist n p) x)
))
= let x' = Seq.slice x 0 (U32.v n) in
let cnt = (U32.v n / k.LP.parser_kind_low) in
FStar.Math.Lemmas.lemma_div_exact (U32.v n) k.LP.parser_kind_low;
FStar.Math.Lemmas.nat_over_pos_is_nat (U32.v n) k.LP.parser_kind_low;
LowParse.Spec.List.parse_list_total_constant_size p cnt x';
LP.parser_kind_prop_equiv LowParse.Spec.List.parse_list_kind (LowParse.Spec.List.parse_list p)
let parse_nlist_total_fixed_size_kind_correct
(n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t)
: Lemma
(requires (
let open LP in
k.parser_kind_subkind == Some ParserStrong /\
k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\
k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures (
LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p) | false | false | EverParse3d.Prelude.fst | {
"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_nlist_total_fixed_size_kind_correct
(n: U32.t)
(#wk: _)
(#k: parser_kind true wk)
(#t: _)
(p: parser k t)
: Lemma
(requires
(let open LP in
k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\
U32.v n % k.parser_kind_low == 0 /\ k.parser_kind_metadata == Some ParserKindMetadataTotal
))
(ensures
(LP.parser_kind_prop (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p))) | [] | EverParse3d.Prelude.parse_nlist_total_fixed_size_kind_correct | {
"file_name": "src/3d/prelude/EverParse3d.Prelude.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t
-> FStar.Pervasives.Lemma
(requires
Mkparser_kind'?.parser_kind_subkind k ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
Mkparser_kind'?.parser_kind_high k ==
FStar.Pervasives.Native.Some (Mkparser_kind'?.parser_kind_low k) /\
FStar.UInt32.v n % Mkparser_kind'?.parser_kind_low k == 0 /\
Mkparser_kind'?.parser_kind_metadata k ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserKindMetadataTotal)
(ensures
LowParse.Spec.Base.parser_kind_prop (LowParse.Spec.Base.total_constant_size_parser_kind (FStar.UInt32.v
n))
(EverParse3d.Prelude.parse_nlist n p)) | {
"end_col": 89,
"end_line": 219,
"start_col": 2,
"start_line": 217
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m) | let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) = | false | null | false | FSet.mem key (domain m) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"Prims.bool"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`: | false | false | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mem : key: a -> m: FStar.FiniteMap.Base.map a b -> Prims.bool | [] | FStar.FiniteMap.Base.mem | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | key: a -> m: FStar.FiniteMap.Base.map a b -> Prims.bool | {
"end_col": 25,
"end_line": 73,
"start_col": 2,
"start_line": 73
} |
|
Prims.Tot | val remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : map a b | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key) | val remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : map a b
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : map a b = | false | null | false | subtract m (FSet.singleton key) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"FStar.FiniteMap.Base.subtract",
"FStar.FiniteSet.Base.singleton"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) | false | false | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : map a b | [] | FStar.FiniteMap.Base.remove | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | key: a -> m: FStar.FiniteMap.Base.map a b -> FStar.FiniteMap.Base.map a b | {
"end_col": 33,
"end_line": 177,
"start_col": 2,
"start_line": 177
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap | let cardinality_zero_iff_empty_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b). {:pattern cardinality m}
cardinality m = 0 <==> m == emptymap | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_iff",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.FiniteMap.Base.cardinality",
"Prims.eq2",
"FStar.FiniteMap.Base.emptymap"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty()); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val cardinality_zero_iff_empty_fact : Prims.logical | [] | FStar.FiniteMap.Base.cardinality_zero_iff_empty_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 40,
"end_line": 200,
"start_col": 2,
"start_line": 199
} |
|
Prims.Tot | val notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : bool | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m) | val notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : bool
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : bool = | false | null | false | not (mem key m) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.op_Negation",
"FStar.FiniteMap.Base.mem",
"Prims.bool"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) | false | false | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) : bool | [] | FStar.FiniteMap.Base.notin | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | key: a -> m: FStar.FiniteMap.Base.map a b -> Prims.bool | {
"end_col": 17,
"end_line": 181,
"start_col": 2,
"start_line": 181
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item) | let empty_or_items_occupied_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b). {:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item} (items m) item) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_or",
"Prims.eq2",
"FStar.FiniteMap.Base.emptymap",
"Prims.l_Exists",
"FStar.Pervasives.Native.tuple2",
"FStar.FiniteMap.Base.items"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_or_items_occupied_fact : Prims.logical | [] | FStar.FiniteMap.Base.empty_or_items_occupied_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 75,
"end_line": 230,
"start_col": 2,
"start_line": 229
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys | let glue_domain_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).
{:pattern domain (glue keys f)}
domain (glue keys f) == keys | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteSet.Base.set",
"FStar.FiniteMap.Base.setfun_t",
"Prims.eq2",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.glue"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val glue_domain_fact : Prims.logical | [] | FStar.FiniteMap.Base.glue_domain_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 32,
"end_line": 298,
"start_col": 2,
"start_line": 297
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m) | let empty_or_domain_occupied_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b). {:pattern domain m}
m == emptymap \/ (exists k. {:pattern mem k m} mem k m) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_or",
"Prims.eq2",
"FStar.FiniteMap.Base.emptymap",
"Prims.l_Exists",
"Prims.b2t",
"FStar.FiniteMap.Base.mem",
"FStar.FiniteMap.Base.domain"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_or_domain_occupied_fact : Prims.logical | [] | FStar.FiniteMap.Base.empty_or_domain_occupied_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 58,
"end_line": 210,
"start_col": 2,
"start_line": 209
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v) | let empty_or_values_occupied_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b). {:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v} (values m) v) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_or",
"Prims.eq2",
"FStar.FiniteMap.Base.emptymap",
"Prims.l_Exists",
"FStar.FiniteMap.Base.values"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_or_values_occupied_fact : Prims.logical | [] | FStar.FiniteMap.Base.empty_or_values_occupied_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 68,
"end_line": 220,
"start_col": 2,
"start_line": 219
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item) | let items_contains_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b) (item: (a * b)). {:pattern (items m) item}
(items m) item <==> FSet.mem (fst item) (domain m) /\ (elements m) (fst item) == Some (snd item) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"FStar.Pervasives.Native.tuple2",
"Prims.l_iff",
"FStar.FiniteMap.Base.items",
"Prims.l_and",
"Prims.b2t",
"FStar.FiniteSet.Base.mem",
"FStar.Pervasives.Native.fst",
"FStar.FiniteMap.Base.domain",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.FiniteMap.Base.elements",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.snd"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item))); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val items_contains_fact : Prims.logical | [] | FStar.FiniteMap.Base.items_contains_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 51,
"end_line": 278,
"start_col": 2,
"start_line": 275
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b))) | let empty_domain_empty_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (u: a). {:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b))) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"Prims.b2t",
"Prims.op_Negation",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.emptymap"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_domain_empty_fact : Prims.logical | [] | FStar.FiniteMap.Base.empty_domain_empty_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 46,
"end_line": 288,
"start_col": 2,
"start_line": 287
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v) | let values_contains_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b). {:pattern (values m) v}
(values m) v <==>
(exists (u: a). {:pattern FSet.mem u (domain m)\/((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_iff",
"FStar.FiniteMap.Base.values",
"Prims.l_Exists",
"Prims.l_and",
"Prims.b2t",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.FiniteMap.Base.elements",
"FStar.Pervasives.Native.Some"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val values_contains_fact : Prims.logical | [] | FStar.FiniteMap.Base.values_contains_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 60,
"end_line": 265,
"start_col": 2,
"start_line": 262
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key) | let merge_element_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).
{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==>
FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key) /\
(FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_imp",
"Prims.b2t",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.merge",
"Prims.l_and",
"Prims.op_Negation",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.FiniteMap.Base.elements"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_element_fact : Prims.logical | [] | FStar.FiniteMap.Base.merge_element_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 89,
"end_line": 379,
"start_col": 2,
"start_line": 376
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_equal_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 <==> (forall key. FSet.mem key (domain m1) = FSet.mem key (domain m2))
/\ (forall key. FSet.mem key (domain m1) ==> (elements m1) key == (elements m2) key) | let map_equal_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b). {:pattern equal m1 m2}
equal m1 m2 <==>
(forall key. FSet.mem key (domain m1) = FSet.mem key (domain m2)) /\
(forall key. FSet.mem key (domain m1) ==> (elements m1) key == (elements m2) key) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_iff",
"FStar.FiniteMap.Base.equal",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"Prims.l_imp",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.FiniteMap.Base.elements"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u]));
let merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key)
/// We represent the following Dafny axiom with `subtract_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U ::
/// { Map#Domain(Map#Subtract(m, s)) }
/// Map#Domain(Map#Subtract(m, s)) == Set#Difference(Map#Domain(m), s));
let subtract_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a).{:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s
/// We represent the following Dafny axiom with `subtract_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U, u: U ::
/// { Map#Elements(Map#Subtract(m, s))[u] }
/// Map#Domain(Map#Subtract(m, s))[u] ==>
/// Map#Elements(Map#Subtract(m, s))[u] == Map#Elements(m)[u]);
let subtract_element_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a) (key: a).{:pattern (elements (subtract m s)) key}
FSet.mem key (domain (subtract m s)) ==> FSet.mem key (domain m) /\ (elements (subtract m s)) key == (elements m) key
/// We represent the following Dafny axiom with `map_equal_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') <==> (forall u : U :: Map#Domain(m)[u] == Map#Domain(m')[u]) &&
/// (forall u : U :: Map#Domain(m)[u] ==> Map#Elements(m)[u] == Map#Elements(m')[u])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_equal_fact : Prims.logical | [] | FStar.FiniteMap.Base.map_equal_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 103,
"end_line": 412,
"start_col": 2,
"start_line": 410
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key') | let insert_elements_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m))\/((elements (insert key value m)) key')}
(key' = key ==>
FSet.mem key' (domain (insert key value m)) /\
(elements (insert key value m)) key' == Some value) /\
(key' <> key ==>
FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m) /\
(elements (insert key value m)) key' == (elements m) key') | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_and",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_Equality",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.insert",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.FiniteMap.Base.elements",
"FStar.Pervasives.Native.Some",
"Prims.op_disEquality",
"Prims.bool"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u'])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val insert_elements_fact : Prims.logical | [] | FStar.FiniteMap.Base.insert_elements_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 82,
"end_line": 337,
"start_col": 2,
"start_line": 332
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2) | let merge_domain_is_union_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b). {:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.eq2",
"FStar.FiniteSet.Base.set",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.merge",
"FStar.FiniteSet.Base.union"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n))); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_domain_is_union_fact : Prims.logical | [] | FStar.FiniteMap.Base.merge_domain_is_union_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 62,
"end_line": 365,
"start_col": 2,
"start_line": 364
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1 | let insert_nonmember_cardinality_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).
{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1 | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_Negation",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"Prims.op_Equality",
"Prims.int",
"FStar.FiniteMap.Base.cardinality",
"FStar.FiniteMap.Base.insert",
"Prims.op_Addition"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val insert_nonmember_cardinality_fact : Prims.logical | [] | FStar.FiniteMap.Base.insert_nonmember_cardinality_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 90,
"end_line": 355,
"start_col": 2,
"start_line": 354
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 subtract_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a).{:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s | let subtract_domain_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a). {:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"FStar.FiniteSet.Base.set",
"Prims.eq2",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.subtract",
"FStar.FiniteSet.Base.difference"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u]));
let merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key)
/// We represent the following Dafny axiom with `subtract_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U ::
/// { Map#Domain(Map#Subtract(m, s)) }
/// Map#Domain(Map#Subtract(m, s)) == Set#Difference(Map#Domain(m), s)); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subtract_domain_fact : Prims.logical | [] | FStar.FiniteMap.Base.subtract_domain_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 57,
"end_line": 389,
"start_col": 2,
"start_line": 388
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 subtract_element_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a) (key: a).{:pattern (elements (subtract m s)) key}
FSet.mem key (domain (subtract m s)) ==> FSet.mem key (domain m) /\ (elements (subtract m s)) key == (elements m) key | let subtract_element_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a) (key: a).
{:pattern (elements (subtract m s)) key}
FSet.mem key (domain (subtract m s)) ==>
FSet.mem key (domain m) /\ (elements (subtract m s)) key == (elements m) key | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"FStar.FiniteSet.Base.set",
"Prims.l_imp",
"Prims.b2t",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain",
"FStar.FiniteMap.Base.subtract",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.FiniteMap.Base.elements"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u]));
let merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key)
/// We represent the following Dafny axiom with `subtract_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U ::
/// { Map#Domain(Map#Subtract(m, s)) }
/// Map#Domain(Map#Subtract(m, s)) == Set#Difference(Map#Domain(m), s));
let subtract_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a).{:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s
/// We represent the following Dafny axiom with `subtract_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U, u: U ::
/// { Map#Elements(Map#Subtract(m, s))[u] }
/// Map#Domain(Map#Subtract(m, s))[u] ==>
/// Map#Elements(Map#Subtract(m, s))[u] == Map#Elements(m)[u]); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subtract_element_fact : Prims.logical | [] | FStar.FiniteMap.Base.subtract_element_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 121,
"end_line": 400,
"start_col": 2,
"start_line": 399
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let map_extensionality_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 ==> m1 == m2 | let map_extensionality_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b). {:pattern equal m1 m2}
equal m1 m2 ==> m1 == m2 | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_imp",
"FStar.FiniteMap.Base.equal",
"Prims.eq2"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u]));
let merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key)
/// We represent the following Dafny axiom with `subtract_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U ::
/// { Map#Domain(Map#Subtract(m, s)) }
/// Map#Domain(Map#Subtract(m, s)) == Set#Difference(Map#Domain(m), s));
let subtract_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a).{:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s
/// We represent the following Dafny axiom with `subtract_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U, u: U ::
/// { Map#Elements(Map#Subtract(m, s))[u] }
/// Map#Domain(Map#Subtract(m, s))[u] ==>
/// Map#Elements(Map#Subtract(m, s))[u] == Map#Elements(m)[u]);
let subtract_element_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a) (key: a).{:pattern (elements (subtract m s)) key}
FSet.mem key (domain (subtract m s)) ==> FSet.mem key (domain m) /\ (elements (subtract m s)) key == (elements m) key
/// We represent the following Dafny axiom with `map_equal_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') <==> (forall u : U :: Map#Domain(m)[u] == Map#Domain(m')[u]) &&
/// (forall u : U :: Map#Domain(m)[u] ==> Map#Elements(m)[u] == Map#Elements(m')[u]));
let map_equal_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 <==> (forall key. FSet.mem key (domain m1) = FSet.mem key (domain m2))
/\ (forall key. FSet.mem key (domain m1) ==> (elements m1) key == (elements m2) key)
/// We represent the following Dafny axiom with `map_extensionality_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') ==> m == m'); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val map_extensionality_fact : Prims.logical | [] | FStar.FiniteMap.Base.map_extensionality_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 28,
"end_line": 422,
"start_col": 2,
"start_line": 421
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 all_finite_map_facts =
cardinality_zero_iff_empty_fact u#b
/\ empty_or_domain_occupied_fact u#b
/\ empty_or_values_occupied_fact u#b
/\ empty_or_items_occupied_fact u#b
/\ map_cardinality_matches_domain_fact u#b
/\ values_contains_fact u#b
/\ items_contains_fact u#b
/\ empty_domain_empty_fact u#b
/\ glue_domain_fact u#b
/\ glue_elements_fact u#b
/\ insert_elements_fact u#b
/\ insert_member_cardinality_fact u#b
/\ insert_nonmember_cardinality_fact u#b
/\ merge_domain_is_union_fact u#b
/\ merge_element_fact u#b
/\ subtract_domain_fact u#b
/\ subtract_element_fact u#b
/\ map_equal_fact u#b
/\ map_extensionality_fact u#b
/\ disjoint_fact u#b | let all_finite_map_facts = | false | null | false | cardinality_zero_iff_empty_fact u#b /\ empty_or_domain_occupied_fact u#b /\
empty_or_values_occupied_fact u#b /\ empty_or_items_occupied_fact u#b /\
map_cardinality_matches_domain_fact u#b /\ values_contains_fact u#b /\ items_contains_fact u#b /\
empty_domain_empty_fact u#b /\ glue_domain_fact u#b /\ glue_elements_fact u#b /\
insert_elements_fact u#b /\ insert_member_cardinality_fact u#b /\
insert_nonmember_cardinality_fact u#b /\ merge_domain_is_union_fact u#b /\ merge_element_fact u#b /\
subtract_domain_fact u#b /\ subtract_element_fact u#b /\ map_equal_fact u#b /\
map_extensionality_fact u#b /\ disjoint_fact u#b | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_and",
"FStar.FiniteMap.Base.cardinality_zero_iff_empty_fact",
"FStar.FiniteMap.Base.empty_or_domain_occupied_fact",
"FStar.FiniteMap.Base.empty_or_values_occupied_fact",
"FStar.FiniteMap.Base.empty_or_items_occupied_fact",
"FStar.FiniteMap.Base.map_cardinality_matches_domain_fact",
"FStar.FiniteMap.Base.values_contains_fact",
"FStar.FiniteMap.Base.items_contains_fact",
"FStar.FiniteMap.Base.empty_domain_empty_fact",
"FStar.FiniteMap.Base.glue_domain_fact",
"FStar.FiniteMap.Base.glue_elements_fact",
"FStar.FiniteMap.Base.insert_elements_fact",
"FStar.FiniteMap.Base.insert_member_cardinality_fact",
"FStar.FiniteMap.Base.insert_nonmember_cardinality_fact",
"FStar.FiniteMap.Base.merge_domain_is_union_fact",
"FStar.FiniteMap.Base.merge_element_fact",
"FStar.FiniteMap.Base.subtract_domain_fact",
"FStar.FiniteMap.Base.subtract_element_fact",
"FStar.FiniteMap.Base.map_equal_fact",
"FStar.FiniteMap.Base.map_extensionality_fact",
"FStar.FiniteMap.Base.disjoint_fact"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u]));
let merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key)
/// We represent the following Dafny axiom with `subtract_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U ::
/// { Map#Domain(Map#Subtract(m, s)) }
/// Map#Domain(Map#Subtract(m, s)) == Set#Difference(Map#Domain(m), s));
let subtract_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a).{:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s
/// We represent the following Dafny axiom with `subtract_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U, u: U ::
/// { Map#Elements(Map#Subtract(m, s))[u] }
/// Map#Domain(Map#Subtract(m, s))[u] ==>
/// Map#Elements(Map#Subtract(m, s))[u] == Map#Elements(m)[u]);
let subtract_element_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a) (key: a).{:pattern (elements (subtract m s)) key}
FSet.mem key (domain (subtract m s)) ==> FSet.mem key (domain m) /\ (elements (subtract m s)) key == (elements m) key
/// We represent the following Dafny axiom with `map_equal_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') <==> (forall u : U :: Map#Domain(m)[u] == Map#Domain(m')[u]) &&
/// (forall u : U :: Map#Domain(m)[u] ==> Map#Elements(m)[u] == Map#Elements(m')[u]));
let map_equal_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 <==> (forall key. FSet.mem key (domain m1) = FSet.mem key (domain m2))
/\ (forall key. FSet.mem key (domain m1) ==> (elements m1) key == (elements m2) key)
/// We represent the following Dafny axiom with `map_extensionality_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') ==> m == m');
let map_extensionality_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 ==> m1 == m2
/// We represent the following Dafny axiom with `disjoint_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V ::
/// { Map#Disjoint(m, m') }
/// Map#Disjoint(m, m') <==> (forall o: U :: {Map#Domain(m)[o]} {Map#Domain(m')[o]} !Map#Domain(m)[o] || !Map#Domain(m')[o]));
let disjoint_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern disjoint m1 m2}
disjoint m1 m2 <==> (forall key.{:pattern FSet.mem key (domain m1) \/ FSet.mem key (domain m2)}
not (FSet.mem key (domain m1)) || not (FSet.mem key (domain m2)))
(**
The predicate `all_finite_map_facts` collects all the Dafny finite-map axioms.
One can bring all these facts into scope with `all_finite_map_facts_lemma ()`.
**) | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val all_finite_map_facts : Prims.logical | [] | FStar.FiniteMap.Base.all_finite_map_facts | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 22,
"end_line": 460,
"start_col": 4,
"start_line": 441
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 disjoint_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern disjoint m1 m2}
disjoint m1 m2 <==> (forall key.{:pattern FSet.mem key (domain m1) \/ FSet.mem key (domain m2)}
not (FSet.mem key (domain m1)) || not (FSet.mem key (domain m2))) | let disjoint_fact = | false | null | false | forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b). {:pattern disjoint m1 m2}
disjoint m1 m2 <==>
(forall key. {:pattern FSet.mem key (domain m1)\/FSet.mem key (domain m2)}
not (FSet.mem key (domain m1)) || not (FSet.mem key (domain m2))) | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.l_Forall",
"Prims.eqtype",
"FStar.FiniteMap.Base.map",
"Prims.l_iff",
"FStar.FiniteMap.Base.disjoint",
"Prims.b2t",
"Prims.op_BarBar",
"Prims.op_Negation",
"FStar.FiniteSet.Base.mem",
"FStar.FiniteMap.Base.domain"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl
val map_as_list (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (items: list (a * b){item_list_doesnt_repeat_keys items /\ (forall key. key_in_item_list key items <==> mem key m)})
/// We represent the Dafny operator [] on maps with `lookup`:
let lookup (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b{mem key m})
: b =
Some?.v ((elements m) key)
/// We represent the Dafny function `Map#Card` with `cardinality`:
///
/// function Map#Card<U,V>(Map U V) : int;
val cardinality (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot nat
/// We represent the Dafny function `Map#Values` with `values`:
///
/// function Map#Values<U,V>(Map U V) : Set V;
val values (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot (b -> prop)
/// We represent the Dafny function `Map#Items` with `items`:
///
/// function Map#Items<U,V>(Map U V) : Set Box;
val items (#a: eqtype) (#b: Type u#b) (m: map a b)
: GTot ((a * b) -> prop)
/// We represent the Dafny function `Map#Empty` with `emptymap`:
///
/// function Map#Empty<U, V>(): Map U V;
val emptymap (#a: eqtype) (#b: Type u#b)
: map a b
/// We represent the Dafny function `Map#Glue` with `glue`.
///
/// function Map#Glue<U, V>([U]bool, [U]V, Ty): Map U V;
val glue (#a: eqtype) (#b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys)
: map a b
/// We represent the Dafny function `Map#Build` with `insert`:
///
/// function Map#Build<U, V>(Map U V, U, V): Map U V;
val insert (#a: eqtype) (#b: Type u#b) (k: a) (v: b) (m: map a b)
: map a b
/// We represent the Dafny function `Map#Merge` with `merge`:
///
/// function Map#Merge<U, V>(Map U V, Map U V): Map U V;
val merge (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: map a b
/// We represent the Dafny function `Map#Subtract` with `subtract`:
///
/// function Map#Subtract<U, V>(Map U V, Set U): Map U V;
val subtract (#a: eqtype) (#b: Type u#b) (m: map a b) (s: FSet.set a)
: map a b
/// We represent the Dafny function `Map#Equal` with `equal`:
///
/// function Map#Equal<U, V>(Map U V, Map U V): bool;
val equal (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny function `Map#Disjoint` with `disjoint`:
///
/// function Map#Disjoint<U, V>(Map U V, Map U V): bool;
val disjoint (#a: eqtype) (#b: Type u#b) (m1: map a b) (m2: map a b)
: prop
/// We represent the Dafny choice operator by `choose`:
///
/// var x: T :| x in s;
val choose (#a: eqtype) (#b: Type u#b) (m: map a b{exists key. mem key m})
: GTot (key: a{mem key m})
/// We add the utility functions `remove` and `notin`:
let remove (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: map a b =
subtract m (FSet.singleton key)
let notin (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b)
: bool =
not (mem key m)
(**
We translate each finite map axiom from the Dafny prelude into an F*
predicate ending in `_fact`.
**)
/// We don't need the following axiom since we return a nat from cardinality:
///
/// axiom (forall<U,V> m: Map U V :: { Map#Card(m) } 0 <= Map#Card(m));
/// We represent the following Dafny axiom with `cardinality_zero_iff_empty_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Card(m) }
/// Map#Card(m) == 0 <==> m == Map#Empty());
let cardinality_zero_iff_empty_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern cardinality m}
cardinality m = 0 <==> m == emptymap
/// We represent the following Dafny axiom with `empty_or_domain_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Domain(m) }
/// m == Map#Empty() || (exists k: U :: Map#Domain(m)[k]));
let empty_or_domain_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern domain m}
m == emptymap \/ (exists k.{:pattern mem k m} mem k m)
/// We represent the following Dafny axiom with `empty_or_values_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Values(m) }
/// m == Map#Empty() || (exists v: V :: Map#Values(m)[v]));
let empty_or_values_occupied_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern values m}
m == emptymap \/ (exists v. {:pattern values m v } (values m) v)
/// We represent the following Dafny axiom with `empty_or_items_occupied_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Map#Items(m) }
/// m == Map#Empty() || (exists k, v: Box :: Map#Items(m)[$Box(#_System._tuple#2._#Make2(k, v))]));
let empty_or_items_occupied_fact =
forall (a: eqtype) (b:Type u#b) (m: map a b).{:pattern items m}
m == emptymap \/ (exists item. {:pattern items m item } (items m) item)
/// We represent the following Dafny axiom with `map_cardinality_matches_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Domain(m)) }
/// Set#Card(Map#Domain(m)) == Map#Card(m));
let map_cardinality_matches_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b).{:pattern FSet.cardinality (domain m)}
FSet.cardinality (domain m) = cardinality m
/// We don't use the following Dafny axioms, which would require
/// treating the values and items as finite sets, which we can't do
/// because we want to allow non-eqtypes as values.
///
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Values(m)) }
/// Set#Card(Map#Values(m)) <= Map#Card(m));
/// axiom (forall<U, V> m: Map U V ::
/// { Set#Card(Map#Items(m)) }
/// Set#Card(Map#Items(m)) == Map#Card(m));
/// We represent the following Dafny axiom with `values_contains_fact`:
///
/// axiom (forall<U,V> m: Map U V, v: V :: { Map#Values(m)[v] }
/// Map#Values(m)[v] ==
/// (exists u: U :: { Map#Domain(m)[u] } { Map#Elements(m)[u] }
/// Map#Domain(m)[u] &&
/// v == Map#Elements(m)[u]));
let values_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (v: b).{:pattern (values m) v}
(values m) v <==>
(exists (u: a).{:pattern FSet.mem u (domain m) \/ ((elements m) u)}
FSet.mem u (domain m) /\ (elements m) u == Some v)
/// We represent the following Dafny axiom with `items_contains_fact`:
///
/// axiom (forall m: Map Box Box, item: Box :: { Map#Items(m)[item] }
/// Map#Items(m)[item] <==>
/// Map#Domain(m)[_System.Tuple2._0($Unbox(item))] &&
/// Map#Elements(m)[_System.Tuple2._0($Unbox(item))] == _System.Tuple2._1($Unbox(item)));
let items_contains_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (item: a * b).{:pattern (items m) item}
(items m) item <==>
FSet.mem (fst item) (domain m)
/\ (elements m) (fst item) == Some (snd item)
/// We represent the following Dafny axiom with `empty_domain_empty_fact`:
///
/// axiom (forall<U, V> u: U ::
/// { Map#Domain(Map#Empty(): Map U V)[u] }
/// !Map#Domain(Map#Empty(): Map U V)[u]);
let empty_domain_empty_fact =
forall (a: eqtype) (b: Type u#b) (u: a).{:pattern FSet.mem u (domain (emptymap #a #b))}
not (FSet.mem u (domain (emptymap #a #b)))
/// We represent the following Dafny axiom with `glue_domain_fact`:
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Domain(Map#Glue(a, b, t)) }
/// Map#Domain(Map#Glue(a, b, t)) == a);
let glue_domain_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern domain (glue keys f)}
domain (glue keys f) == keys
/// We represent the following Dafny axiom with `glue_elements_fact`.
/// But we have to change it because our version of `Map#Elements`
/// returns a map to an optional value.
///
/// axiom (forall<U, V> a: [U]bool, b: [U]V, t: Ty ::
/// { Map#Elements(Map#Glue(a, b, t)) }
/// Map#Elements(Map#Glue(a, b, t)) == b);
let glue_elements_fact =
forall (a: eqtype) (b: Type u#b) (keys: FSet.set a) (f: setfun_t a b keys).{:pattern elements (glue keys f)}
domain (glue keys f) == keys
/\ elements (glue keys f) == f
/// We don't need the following Dafny axiom since the type of `glue` implies it:
///
/// axiom (forall a: [Box]bool, b: [Box]Box, t0, t1: Ty ::
/// { Map#Glue(a, b, TMap(t0, t1)) }
/// // In the following line, no trigger needed, since the quantifier only gets used in negative contexts
/// (forall bx: Box :: a[bx] ==> $IsBox(bx, t0) && $IsBox(b[bx], t1))
/// ==>
/// $Is(Map#Glue(a, b, TMap(t0, t1)), TMap(t0, t1)));
/// We represent the following Dafny axiom with `insert_elements_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, u': U, v: V ::
/// { Map#Domain(Map#Build(m, u, v))[u'] } { Map#Elements(Map#Build(m, u, v))[u'] }
/// (u' == u ==> Map#Domain(Map#Build(m, u, v))[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == v) &&
/// (u' != u ==> Map#Domain(Map#Build(m, u, v))[u'] == Map#Domain(m)[u'] &&
/// Map#Elements(Map#Build(m, u, v))[u'] == Map#Elements(m)[u']));
let insert_elements_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (key': a) (value: b).
{:pattern FSet.mem key' (domain (insert key value m)) \/ ((elements (insert key value m)) key')}
(key' = key ==> FSet.mem key' (domain (insert key value m))
/\ (elements (insert key value m)) key' == Some value)
/\ (key' <> key ==> FSet.mem key' (domain (insert key value m)) = FSet.mem key' (domain m)
/\ (elements (insert key value m)) key' == (elements m) key')
/// We represent the following Dafny axiom with `insert_member_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m));
let insert_member_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
FSet.mem key (domain m) ==> cardinality (insert key value m) = cardinality m
/// We represent the following Dafny axiom with `insert_nonmember_cardinality_fact`:
///
/// axiom (forall<U, V> m: Map U V, u: U, v: V :: { Map#Card(Map#Build(m, u, v)) }
/// !Map#Domain(m)[u] ==> Map#Card(Map#Build(m, u, v)) == Map#Card(m) + 1);
let insert_nonmember_cardinality_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (key: a) (value: b).{:pattern cardinality (insert key value m)}
not (FSet.mem key (domain m)) ==> cardinality (insert key value m) = cardinality m + 1
/// We represent the following Dafny axiom with `merge_domain_is_union_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V ::
/// { Map#Domain(Map#Merge(m, n)) }
/// Map#Domain(Map#Merge(m, n)) == Set#Union(Map#Domain(m), Map#Domain(n)));
let merge_domain_is_union_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern domain (merge m1 m2)}
domain (merge m1 m2) == FSet.union (domain m1) (domain m2)
/// We represent the following Dafny axiom with `merge_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, n: Map U V, u: U ::
/// { Map#Elements(Map#Merge(m, n))[u] }
/// Map#Domain(Map#Merge(m, n))[u] ==>
/// (!Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(m)[u]) &&
/// (Map#Domain(n)[u] ==> Map#Elements(Map#Merge(m, n))[u] == Map#Elements(n)[u]));
let merge_element_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b) (key: a).{:pattern (elements (merge m1 m2)) key}
FSet.mem key (domain (merge m1 m2)) ==>
(not (FSet.mem key (domain m2)) ==> FSet.mem key (domain m1) /\ (elements (merge m1 m2)) key == (elements m1) key)
/\ (FSet.mem key (domain m2) ==> (elements (merge m1 m2)) key == (elements m2) key)
/// We represent the following Dafny axiom with `subtract_domain_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U ::
/// { Map#Domain(Map#Subtract(m, s)) }
/// Map#Domain(Map#Subtract(m, s)) == Set#Difference(Map#Domain(m), s));
let subtract_domain_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a).{:pattern domain (subtract m s)}
domain (subtract m s) == FSet.difference (domain m) s
/// We represent the following Dafny axiom with `subtract_element_fact`:
///
/// axiom (forall<U, V> m: Map U V, s: Set U, u: U ::
/// { Map#Elements(Map#Subtract(m, s))[u] }
/// Map#Domain(Map#Subtract(m, s))[u] ==>
/// Map#Elements(Map#Subtract(m, s))[u] == Map#Elements(m)[u]);
let subtract_element_fact =
forall (a: eqtype) (b: Type u#b) (m: map a b) (s: FSet.set a) (key: a).{:pattern (elements (subtract m s)) key}
FSet.mem key (domain (subtract m s)) ==> FSet.mem key (domain m) /\ (elements (subtract m s)) key == (elements m) key
/// We represent the following Dafny axiom with `map_equal_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') <==> (forall u : U :: Map#Domain(m)[u] == Map#Domain(m')[u]) &&
/// (forall u : U :: Map#Domain(m)[u] ==> Map#Elements(m)[u] == Map#Elements(m')[u]));
let map_equal_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 <==> (forall key. FSet.mem key (domain m1) = FSet.mem key (domain m2))
/\ (forall key. FSet.mem key (domain m1) ==> (elements m1) key == (elements m2) key)
/// We represent the following Dafny axiom with `map_extensionality_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V::
/// { Map#Equal(m, m') }
/// Map#Equal(m, m') ==> m == m');
let map_extensionality_fact =
forall (a: eqtype) (b: Type u#b) (m1: map a b) (m2: map a b).{:pattern equal m1 m2}
equal m1 m2 ==> m1 == m2
/// We represent the following Dafny axiom with `disjoint_fact`:
///
/// axiom (forall<U, V> m: Map U V, m': Map U V ::
/// { Map#Disjoint(m, m') }
/// Map#Disjoint(m, m') <==> (forall o: U :: {Map#Domain(m)[o]} {Map#Domain(m')[o]} !Map#Domain(m)[o] || !Map#Domain(m')[o])); | false | true | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val disjoint_fact : Prims.logical | [] | FStar.FiniteMap.Base.disjoint_fact | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.logical | {
"end_col": 91,
"end_line": 433,
"start_col": 2,
"start_line": 431
} |
|
Prims.Tot | val item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool =
match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl | val item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool
let rec item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool = | false | null | false | match items with
| [] -> true
| (k, v) :: tl -> not (key_in_item_list k tl) && item_list_doesnt_repeat_keys tl | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Prims.op_AmpAmp",
"Prims.op_Negation",
"FStar.FiniteMap.Base.key_in_item_list",
"FStar.FiniteMap.Base.item_list_doesnt_repeat_keys",
"Prims.bool"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`:
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl | false | false | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val item_list_doesnt_repeat_keys (#a: eqtype) (#b: Type u#b) (items: list (a * b)) : bool | [
"recursion"
] | FStar.FiniteMap.Base.item_list_doesnt_repeat_keys | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | items: Prims.list (a * b) -> Prims.bool | {
"end_col": 82,
"end_line": 85,
"start_col": 2,
"start_line": 83
} |
Prims.Tot | val key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool | [
{
"abbrev": true,
"full_module": "FStar.FiniteSet.Base",
"short_module": "FSet"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "FLT"
},
{
"abbrev": false,
"full_module": "FStar.FunctionalExtensionality",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.FiniteMap",
"short_module": null
},
{
"abbrev": 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 rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool =
match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl | val key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool
let rec key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool = | false | null | false | match items with
| [] -> false
| (k, v) :: tl -> key = k || key_in_item_list key tl | {
"checked_file": "FStar.FiniteMap.Base.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.FiniteSet.Base.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.FiniteMap.Base.fsti"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Prims.op_BarBar",
"Prims.op_Equality",
"FStar.FiniteMap.Base.key_in_item_list",
"Prims.bool"
] | [] | (*
Copyright 2008-2021 John Li, Jay Lorch, Rustan Leino, Alex Summers,
Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
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.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module declares a type and functions used for modeling
finite maps as they're modeled in Dafny.
@summary Type and functions for modeling finite maps
*)
module FStar.FiniteMap.Base
open FStar.FunctionalExtensionality
module FLT = FStar.List.Tot
module FSet = FStar.FiniteSet.Base
type setfun_t (a: eqtype)
(b: Type u#b)
(s: FSet.set a) =
f: (a ^-> option b){forall (key: a). FSet.mem key s == Some? (f key)}
val map (a: eqtype) ([@@@ strictly_positive] b: Type u#b)
: Type u#b
(**
We translate each Dafny sequence function prefixed with `Map#`
into an F* function.
**)
/// We represent the Dafny function `Map#Domain` with `domain`:
///
/// function Map#Domain<U,V>(Map U V) : Set U;
val domain (#a: eqtype) (#b: Type u#b) (m: map a b)
: FSet.set a
/// We represent the Dafny function `Map#Elements` with `elements`:
///
/// function Map#Elements<U,V>(Map U V) : [U]V;
val elements (#a: eqtype) (#b: Type u#b) (m: map a b)
: setfun_t a b (domain m)
/// We represent the Dafny operator `in` on maps with `mem`:
let mem (#a: eqtype) (#b: Type u#b) (key: a) (m: map a b) =
FSet.mem key (domain m)
/// We can convert a map to a list of pairs with `map_as_list`: | false | false | FStar.FiniteMap.Base.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val key_in_item_list (#a: eqtype) (#b: Type u#b) (key: a) (items: list (a * b)) : bool | [
"recursion"
] | FStar.FiniteMap.Base.key_in_item_list | {
"file_name": "ulib/FStar.FiniteMap.Base.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | key: a -> items: Prims.list (a * b) -> Prims.bool | {
"end_col": 54,
"end_line": 80,
"start_col": 2,
"start_line": 78
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.