file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
listlengths
0
2
mutual_with
listlengths
0
11
ideal_premises
listlengths
0
236
proof_features
listlengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
PulseCore.Atomic.fst
PulseCore.Atomic.equiv
val equiv (#p #q: slprop) (pf: slprop_equiv p q) : squash (p == q)
val equiv (#p #q: slprop) (pf: slprop_equiv p q) : squash (p == q)
let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 25, "end_line": 18, "start_col": 0, "start_line": 15 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pf: PulseCore.InstantiatedSemantics.slprop_equiv p q -> Prims.squash (p == q)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.InstantiatedSemantics.slprop_equiv", "PulseCore.InstantiatedSemantics.slprop_equiv_elim", "Prims.squash", "FStar.Squash.return_squash", "Prims.eq2" ]
[]
false
false
true
false
false
let equiv (#p #q: slprop) (pf: slprop_equiv p q) : squash (p == q) =
let _:squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q
false
PulseCore.Atomic.fst
PulseCore.Atomic.bind_atomic
val bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) : stt_atomic b #(join_obs obs1 obs2) opens pre1 post2
val bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) : stt_atomic b #(join_obs obs1 obs2) opens pre1 post2
let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 67, "start_col": 0, "start_line": 56 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: PulseCore.Atomic.stt_atomic a opens pre1 post1 -> e2: (x: a -> PulseCore.Atomic.stt_atomic b opens (post1 x) post2) -> PulseCore.Atomic.stt_atomic b opens pre1 post2
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "Prims.b2t", "PulseCore.Observability.at_most_one_observable", "PulseCore.Action.inames", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_atomic", "PulseCore.Action.bind", "PulseCore.Observability.join_obs" ]
[]
false
false
false
false
false
let bind_atomic (#a: Type u#a) (#b: Type u#b) (#obs1: _) (#obs2: observability{at_most_one_observable obs1 obs2}) (#opens: inames) (#pre1: slprop) (#post1: (a -> slprop)) (#post2: (b -> slprop)) (e1: stt_atomic a #obs1 opens pre1 post1) (e2: (x: a -> stt_atomic b #obs2 opens (post1 x) post2)) =
A.bind e1 e2
false
PulseCore.Atomic.fst
PulseCore.Atomic.frame_atomic
val frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame)
val frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame)
let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 117, "start_col": 0, "start_line": 108 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
frame: PulseCore.InstantiatedSemantics.slprop -> e: PulseCore.Atomic.stt_atomic a opens pre post -> PulseCore.Atomic.stt_atomic a opens (pre ** frame) (fun x -> post x ** frame)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "PulseCore.Action.inames", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_atomic", "PulseCore.Action.frame", "PulseCore.InstantiatedSemantics.op_Star_Star" ]
[]
false
false
false
false
false
let frame_atomic (#a: Type u#a) (#obs: observability) (#opens: inames) (#pre: slprop) (#post: (a -> slprop)) (frame: slprop) (e: stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) =
A.frame e
false
SimplePrintfReify.fst
SimplePrintfReify.concat_lemma
val concat_lemma (s1 s2: list char) (l1 l2: list dir) : Lemma (requires (reify (parse_format s1) () = Some l1 /\ reify (parse_format s2) () = Some l2)) (ensures (reify (parse_format (s1 @ s2)) () = Some (l1 @ l2))) (decreases s1)
val concat_lemma (s1 s2: list char) (l1 l2: list dir) : Lemma (requires (reify (parse_format s1) () = Some l1 /\ reify (parse_format s2) () = Some l2)) (ensures (reify (parse_format (s1 @ s2)) () = Some (l1 @ l2))) (decreases s1)
let rec concat_lemma (s1 s2 : list char) (l1 l2:list dir) : Lemma (requires (reify (parse_format s1) () = Some l1 /\ reify (parse_format s2) () = Some l2)) (ensures (reify (parse_format (s1 @ s2)) () = Some (l1@l2))) (decreases s1) = match s1 with | [] -> () | ['%'] -> () | '%' :: c :: s1' -> begin match c with | '%' | 'b' | 'd' | 'c' |'s' -> begin match l1 with | _ :: l1' -> concat_lemma s1' s2 l1' l2 end | _ -> () end | c :: s1' -> begin match l1 with | _ :: l1' -> concat_lemma s1' s2 l1' l2 end
{ "file_name": "examples/printf/SimplePrintfReify.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 187, "start_col": 0, "start_line": 169 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module SimplePrintfReify open FStar.Char open FStar.String module List = FStar.List.Tot // A variant of SimplePrintf that uses reify on the Ex implementation // of parse_format // For a start here's an alpha renamed version of Ex to avoid clashes // with the prims variant of Ex (which is not defined using dm4free // and is not marked as `total`) (* The underlying representation type *) let ex (a:Type) = unit -> M (option a) (* Monad definition *) val return_ex : (a:Type) -> (x:a) -> Tot (ex a) let return_ex a x = fun _ -> Some x val bind_ex : (a:Type) -> (b:Type) -> (f:ex a) -> (g:a -> Tot (ex b)) -> Tot (ex b) let bind_ex a b f g = fun _ -> let r = f () in match r with | None -> None | Some x -> g x () (* DMFF does not support yet polymorphic actions *) (* Returning something in [False] allow to derive the usual raise below *) let raise_ex (_:exn) : Tot (ex False) = fun _ -> None (* Define the new effect using DM4F *) total reifiable reflectable new_effect { XEXN : (a:Type) -> Effect with repr = ex ; bind = bind_ex ; return = return_ex ; raise = raise_ex } (* A lift from `Pure´ into the new effect *) (* unfold let lift_pure_ex_wp (a:Type) (wp:pure_wp a) (_:unit) (p:XEXN?.post a) = *) (* wp (fun a -> p (Some a)) *) (* sub_effect PURE ~> XEXN = lift_pure_ex_wp *) reifiable let raise (#a:Type0) (e:exn) : XEXN a (fun _ p -> p None) = let x = XEXN?.raise e in begin match x with end (* An effect to alias easily write pre- and postconditions *) (* Note: we use Type0 instead of XEXN.pre to avoid having to thunk everything. *) effect Xexn (a:Type) (pre:Type0) (post:XEXN?.post a) = XEXN a (fun (_:unit) (p:XEXN?.post a) -> pre /\ (forall (r:option a). (pre /\ post r) ==> p r)) (* Another alias. Ex a is the effect type for total exception-throwing * programs. i.e. Any program of type `Ex a´ will throw or finish * correctly, but never loop. *) effect Xex (a:Type) = XEXN a (fun _ p -> forall (x:option a). p x) // arguments to printf type arg = | Bool | Int | Char | String // directives to printf type dir = | Lit : char -> dir | Arg : arg -> dir let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> Tot (dir_type ds') let dir_type' ds = dir_type ds let rec string_of_dirs ds (k:string -> Tot string) : Tot (dir_type ds) = match ds with | [] -> k "" | Lit c :: ds' -> coerce_eq () ( string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) ) | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> k (match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x) ^ res) let example1 : string = string_of_dirs [Arg Int; Arg String] (fun s -> s) 42 " answer" exception InvalidFormatString (* TODO: can we get rid of the two `let x` or are they really required? *) reifiable let rec parse_format (s:list char) : Xex (list dir) = match s with | [] -> [] | '%' :: c :: s' -> let d = match c with | '%' -> Lit '%' | 'b' -> Arg Bool | 'd' -> Arg Int | 'c' -> Arg Char | 's' -> Arg String | _ -> raise InvalidFormatString in let x = parse_format s' in d :: x | '%' :: [] -> raise InvalidFormatString | c :: s' -> let x = parse_format s' in Lit c :: x let parse_format_pure (s:list char) : option (list dir) = reify (parse_format s) () let rec parse_format_string (s:string) : Tot (option (list dir)) = parse_format_pure (list_of_string s) let sprintf (s:string{normalize_term #bool (Some? (parse_format_string s))}) : Tot (normalize_term (dir_type (Some?.v (parse_format_string s)))) = string_of_dirs (Some?.v (parse_format_string s)) (fun s -> s) let yyy = parse_format_pure ['%'] == None let xxx = parse_format_pure ['%'; 'd'; '='; '%'; 's'] let example_error_lemma () : Lemma (parse_format_pure ['%'] == None) = () (* Bad interaction with raise, results in a Failure("Impossible") *) (* assert_norm (parse_format_pure ['%'] == None) *) let example3_lemma () : Lemma (parse_format_pure ['%'; 'd'; '='; '%'; 's'] == Some [Arg Int; Lit '='; Arg String]) = assert_norm (parse_format_pure ['%'; 'd'; '='; '%'; 's'] == Some [Arg Int; Lit '='; Arg String]) let example4_lemma () : Lemma (parse_format_string "%d=%s" == Some [Arg Int; Lit '='; Arg String]) = assert_norm (parse_format_string "%d=%s" == Some [Arg Int; Lit '='; Arg String]) let example5 : string = sprintf "%d=%s" 42 " answer"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "SimplePrintfReify.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "List" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: Prims.list FStar.String.char -> s2: Prims.list FStar.String.char -> l1: Prims.list SimplePrintfReify.dir -> l2: Prims.list SimplePrintfReify.dir -> FStar.Pervasives.Lemma (requires reify (SimplePrintfReify.parse_format s1) () = FStar.Pervasives.Native.Some l1 /\ reify (SimplePrintfReify.parse_format s2) () = FStar.Pervasives.Native.Some l2) (ensures reify (SimplePrintfReify.parse_format (s1 @ s2)) () = FStar.Pervasives.Native.Some (l1 @ l2) ) (decreases s1)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.list", "FStar.String.char", "SimplePrintfReify.dir", "SimplePrintfReify.concat_lemma", "Prims.unit", "FStar.Char.char", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "FStar.Pervasives.Native.option", "SimplePrintfReify.parse_format", "FStar.Pervasives.Native.Some", "Prims.squash", "FStar.List.Tot.Base.append", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec concat_lemma (s1 s2: list char) (l1 l2: list dir) : Lemma (requires (reify (parse_format s1) () = Some l1 /\ reify (parse_format s2) () = Some l2)) (ensures (reify (parse_format (s1 @ s2)) () = Some (l1 @ l2))) (decreases s1) =
match s1 with | [] -> () | ['%'] -> () | '%' :: c :: s1' -> (match c with | '%' | 'b' | 'd' | 'c' | 's' -> (match l1 with | _ :: l1' -> concat_lemma s1' s2 l1' l2) | _ -> ()) | c :: s1' -> match l1 with | _ :: l1' -> concat_lemma s1' s2 l1' l2
false
PulseCore.Atomic.fst
PulseCore.Atomic.lift_atomic1
val lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post
val lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post
let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 96, "start_col": 0, "start_line": 88 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: PulseCore.Atomic.stt_atomic a opens pre post -> PulseCore.InstantiatedSemantics.stt a pre post
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "PulseCore.Action.inames", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_atomic", "PulseCore.Action.lift1", "PulseCore.InstantiatedSemantics.stt" ]
[]
false
false
false
false
false
let lift_atomic1 (#a: Type u#1) (#obs: _) (#opens: inames) (#pre: slprop) (#post: (a -> slprop)) (e: stt_atomic a #obs opens pre post) : stt a pre post =
A.lift1 e
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_dsum_cases_known_payload
val gaccessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (gaccessor (parse_dsum_cases' t f g (Known k)) (dsnd (f k)) (clens_dsum_cases_payload t (Known k)))
val gaccessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (gaccessor (parse_dsum_cases' t f g (Known k)) (dsnd (f k)) (clens_dsum_cases_payload t (Known k)))
let gaccessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (gaccessor (parse_dsum_cases' t f g (Known k)) (dsnd (f k)) (clens_dsum_cases_payload t (Known k))) = synth_dsum_case_injective t (Known k); synth_dsum_case_inverse t (Known k); synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) (); gaccessor_ext (gaccessor_synth (dsnd (f k)) (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) ()) (clens_dsum_cases_payload t (Known k)) ()
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 2102, "start_col": 0, "start_line": 2089 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos #push-options "--z3rlimit 32" let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload #pop-options let valid_dsum_elim_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Unknown? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid g h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload inline_for_extraction let jump_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = jumper (parse_dsum_cases' s f g x) let jump_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : jump_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let jump_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (jump_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (jump_dsum_cases_t s f g x))) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: jump_dsum_cases_t s f g x) input len else (iff () <: jump_dsum_cases_t s f g x) input len inline_for_extraction let jump_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (jump_dsum_cases_eq s f g x)) = jump_dsum_cases_if' s f g x inline_for_extraction let jump_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = synth_dsum_case_injective s x; match x with | Known x' -> jump_synth (f' x') (synth_dsum_case s (Known x')) () <: jumper (parse_dsum_cases' s f g x) | Unknown x' -> jump_synth g' (synth_dsum_case s (Unknown x')) () <: jumper (parse_dsum_cases' s f g x) inline_for_extraction let jump_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> jump_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> jump_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> jump_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let jump_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jumper (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input pos; valid_facts (parse_dsum_cases s f g x) h input pos; parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input pos) in jump_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 16" inline_for_extraction let jump_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (jumper (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: jumper g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (jump_dsum_cases_t t f g)) : Tot (jumper (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input pos) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input pos in [@inline_let] let _ = valid_facts p h input pos in let pos_after_tag = v input pos in let tg = p32 input pos in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input pos_after_tag in destr (jump_dsum_cases_eq t f g) (jump_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options inline_for_extraction let read_dsum_cases' (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #rrel #rel input pos -> [@inline_let] let _ = synth_dsum_case_injective t x in match x with | Known x' -> read_synth' (dsnd (f x')) (synth_dsum_case t (Known x')) (f32 x') () input pos | Unknown x' -> read_synth' g (synth_dsum_case t (Unknown x')) g32 () input pos inline_for_extraction let read_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot Type = leaf_reader (parse_dsum_cases' t f g (Known k)) let read_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) (x y : read_dsum_cases_t t f g k) : GTot Type0 = True inline_for_extraction let read_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (if_combinator _ (read_dsum_cases_t_eq t f g k)) = fun cond (sv_true: cond_true cond -> Tot (read_dsum_cases_t t f g k)) (sv_false: cond_false cond -> Tot (read_dsum_cases_t t f g k)) #_ #_ input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let read_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #_ #_ input pos -> match x with | Known k -> destr _ (read_dsum_cases_t_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> read_dsum_cases' t f f32 g g32 (Known k)) k input pos | Unknown r -> read_dsum_cases' t f f32 g g32 (Unknown r) input pos #push-options "--z3rlimit 16" inline_for_extraction let read_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader (parse_maybe_enum_key p (dsum_enum t))) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) : Tot (leaf_reader (parse_dsum t p f g)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_maybe_enum_key j (dsum_enum t) input pos in valid_facts (parse_dsum_cases' t f g k) h input pos' ; read_dsum_cases t f f32 g g32 destr k input pos' #pop-options inline_for_extraction let serialize32_dsum_type_of_tag (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_type_of_tag t f sf g sg tg)) = match tg with | Known x' -> serialize32_ext (dsnd (f x')) (sf x') (sf32 x') (parse_dsum_type_of_tag t f g tg) () | Unknown x' -> serialize32_ext g sg sg32 (parse_dsum_type_of_tag t f g tg) () inline_for_extraction let serialize32_dsum_cases_aux (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = [@inline_let] let _ = synth_dsum_case_injective t tg in [@inline_let] let _ = synth_dsum_case_inverse t tg in serialize32_synth (serialize32_dsum_type_of_tag t f sf sf32 sg32 tg) (synth_dsum_case t tg) (synth_dsum_case_recip t tg) (fun x -> synth_dsum_case_recip t tg x) () inline_for_extraction let serialize32_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot Type = serializer32 (serialize_dsum_cases t f sf g sg (Known k)) let serialize32_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) (x y: serialize32_dsum_cases_t t f sf g sg k) : GTot Type0 = True inline_for_extraction let serialize32_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot (if_combinator _ (serialize32_dsum_cases_t_eq t f sf g sg k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) (sv_false: (cond_false cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) x #rrel #rel output pos -> if cond then (sv_true () x output pos) else (sv_false () x output pos) inline_for_extraction let serialize32_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = fun x #rrel #rel output pos -> match tg with | Known k -> destr _ (serialize32_dsum_cases_t_if t f sf g sg) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Known k)) k x output pos | Unknown r -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Unknown r) x output pos inline_for_extraction let serialize32_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_maybe_enum_key _ s (dsum_enum t))) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) : Tot (serializer32 (serialize_dsum t s f sf g sg)) = fun x #_ #_ output pos -> [@inline_let] let _ = serialize_dsum_eq' t s f sf g sg x in let tg = dsum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_dsum_cases t f sf sf32 sg32 destr tg) tg x output pos let clens_dsum_tag (s: dsum) : Tot (clens (dsum_type s) (dsum_key s)) = { clens_cond = (fun _ -> True); clens_get = dsum_tag_of_data s; } let gaccessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) (parse_maybe_enum_key p (dsum_enum t)) (clens_dsum_tag t)) = gaccessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) inline_for_extraction let accessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_dsum_tag t p f g)) = accessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) let clens_dsum_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_type s) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_type s) -> dsum_tag_of_data s x == k); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (dsum_tag_of_data s x == k)) (ensures (fun _ -> True))); } let clens_dsum_unknown_payload (s: dsum) : Tot (clens (dsum_type s) (dsum_type_of_unknown_tag s)) = { clens_cond = (fun (x: dsum_type s) -> Unknown? (dsum_tag_of_data s x)); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s (dsum_tag_of_data s x) x <: Ghost (dsum_type_of_unknown_tag s) (requires (Unknown? (dsum_tag_of_data s x))) (ensures (fun _ -> True))); } #push-options "--z3rlimit 16" let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res } )) let gaccessor_clens_dsum_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_injective t p f g k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_no_lookahead t p f g k x)); gaccessor_prop_equiv (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) (gaccessor_clens_dsum_payload' t p f g k); gaccessor_clens_dsum_payload' t p f g k inline_for_extraction let accessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_payload t k).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_payload t p f g k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_payload t p f g k) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (accessor (gaccessor_clens_dsum_payload t p f g k)) = fun #rrel #rel -> accessor_clens_dsum_payload' t j f g k #rrel #rel #push-options "--z3rlimit 16" let gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (tg, consumed) -> let k = maybe_enum_key_of_repr (dsum_enum t) tg in synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) g (clens_dsum_unknown_payload t) input res } )) let gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_unknown_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_unknown_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_unknown_payload_injective t p f g x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_unknown_payload_no_lookahead t p f g x)); gaccessor_prop_equiv (parse_dsum t p f g) g (clens_dsum_unknown_payload t) (gaccessor_clens_dsum_unknown_payload' t p f g); gaccessor_clens_dsum_unknown_payload' t p f g inline_for_extraction let accessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_unknown_payload t).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_unknown_payload t p f g) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_unknown_payload t p f g) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_unknown_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p { kt.parser_kind_subkind == Some ParserStrong }) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_clens_dsum_unknown_payload t p f g)) = fun #rrel #rel -> accessor_clens_dsum_unknown_payload' t j f g #rrel #rel let clens_dsum_cases_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_cases s k) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_cases s k) -> True); clens_get = (fun (x: dsum_cases s k) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.dsum -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> k: LowParse.Spec.Sum.dsum_known_key t -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.Sum.parse_dsum_cases' t f g (LowParse.Spec.Enum.Known k)) (FStar.Pervasives.dsnd (f k)) (LowParse.Low.Sum.clens_dsum_cases_payload t (LowParse.Spec.Enum.Known k))
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Sum.dsum", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Low.Base.Spec.gaccessor_ext", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Sum.dsum_cases", "LowParse.Spec.Enum.Known", "LowParse.Spec.Sum.dsum_key_type", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_enum", "LowParse.Spec.Combinators.parse_synth", "FStar.Pervasives.dsnd", "LowParse.Spec.Sum.synth_dsum_case", "LowParse.Low.Combinators.clens_synth", "LowParse.Spec.Sum.synth_dsum_case_recip", "LowParse.Low.Combinators.gaccessor_synth", "LowParse.Low.Sum.clens_dsum_cases_payload", "Prims.unit", "LowParse.Spec.Combinators.synth_injective_synth_inverse_synth_inverse_recip", "LowParse.Spec.Base.refine_with_tag", "LowParse.Spec.Sum.dsum_key", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.dsum_tag_of_data", "LowParse.Spec.Sum.dsum_type_of_tag", "LowParse.Spec.Sum.synth_dsum_case_inverse", "LowParse.Spec.Sum.synth_dsum_case_injective", "LowParse.Low.Base.Spec.gaccessor", "LowParse.Spec.Sum.parse_dsum_cases_kind", "LowParse.Spec.Sum.parse_dsum_cases'" ]
[]
false
false
false
false
false
let gaccessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (gaccessor (parse_dsum_cases' t f g (Known k)) (dsnd (f k)) (clens_dsum_cases_payload t (Known k))) =
synth_dsum_case_injective t (Known k); synth_dsum_case_inverse t (Known k); synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) (); gaccessor_ext (gaccessor_synth (dsnd (f k)) (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) ()) (clens_dsum_cases_payload t (Known k)) ()
false
PulseCore.Atomic.fst
PulseCore.Atomic.lift_atomic2
val lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post
val lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post
let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 106, "start_col": 0, "start_line": 98 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: PulseCore.Atomic.stt_atomic a opens pre post -> PulseCore.InstantiatedSemantics.stt a pre post
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "PulseCore.Action.inames", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_atomic", "PulseCore.Action.lift2", "PulseCore.InstantiatedSemantics.stt" ]
[]
false
false
false
false
false
let lift_atomic2 (#a: Type u#2) (#obs: _) (#opens: inames) (#pre: slprop) (#post: (a -> slprop)) (e: stt_atomic a #obs opens pre post) : stt a pre post =
A.lift2 e
false
PulseCore.Atomic.fst
PulseCore.Atomic.return_atomic
val return_atomic (#a:Type u#a) (x:a) (p:a -> slprop) : stt_atomic a #Neutral emp_inames (p x) (fun r -> p r ** pure (r == x))
val return_atomic (#a:Type u#a) (x:a) (p:a -> slprop) : stt_atomic a #Neutral emp_inames (p x) (fun r -> p r ** pure (r == x))
let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 52, "start_col": 0, "start_line": 46 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> p: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> PulseCore.Atomic.stt_atomic a PulseCore.Action.emp_inames (p x) (fun r -> p r ** PulseCore.InstantiatedSemantics.pure (r == x))
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Pervasives.coerce_eq", "PulseCore.Atomic.stt_atomic", "PulseCore.Observability.Unobservable", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.pure", "Prims.eq2", "PulseCore.Observability.Neutral", "PulseCore.Atomic.return_atomic'", "Prims.unit", "PulseCore.Atomic.pure_trivial", "PulseCore.Atomic.emp_unit_r" ]
[]
false
false
false
false
false
let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) =
emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post)
false
PulseCore.Atomic.fst
PulseCore.Atomic.pure_equiv
val pure_equiv: p: prop -> q: prop -> squash (p <==> q) -> slprop_equiv (pure p) (pure q)
val pure_equiv: p: prop -> q: prop -> squash (p <==> q) -> slprop_equiv (pure p) (pure q)
let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 13, "start_col": 0, "start_line": 10 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> q: Prims.prop -> _: Prims.squash (p <==> q) -> PulseCore.InstantiatedSemantics.slprop_equiv (PulseCore.InstantiatedSemantics.pure p) (PulseCore.InstantiatedSemantics.pure q)
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.squash", "Prims.l_iff", "PulseCore.InstantiatedSemantics.slprop_equiv_refl", "PulseCore.InstantiatedSemantics.pure", "Prims.unit", "FStar.PropositionalExtensionality.apply", "PulseCore.InstantiatedSemantics.slprop_equiv" ]
[]
false
false
false
false
false
let pure_equiv (p: prop) (q: prop) (_: squash (p <==> q)) : slprop_equiv (pure p) (pure q) =
FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p)
false
PulseCore.Atomic.fst
PulseCore.Atomic.emp_unit_r
val emp_unit_r (p: slprop) : squash (p ** emp == p)
val emp_unit_r (p: slprop) : squash (p ** emp == p)
let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; }
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 38, "start_col": 0, "start_line": 30 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; }
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: PulseCore.InstantiatedSemantics.slprop -> Prims.squash (p ** PulseCore.InstantiatedSemantics.emp == p)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Calc.calc_finish", "Prims.eq2", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.emp", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "PulseCore.Atomic.equiv", "PulseCore.InstantiatedSemantics.slprop_equiv_comm", "Prims.squash", "PulseCore.InstantiatedSemantics.slprop_equiv_unit" ]
[]
false
false
true
false
false
let emp_unit_r (p: slprop) : squash (p ** emp == p) =
calc ( == ) { (p ** emp); ( == ) { equiv (slprop_equiv_comm p emp) } (emp ** p); ( == ) { equiv (slprop_equiv_unit p) } p; }
false
PulseCore.Atomic.fst
PulseCore.Atomic.pure_trivial
val pure_trivial: p: prop -> squash p -> squash (pure p == emp)
val pure_trivial: p: prop -> squash p -> squash (pure p == emp)
let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; }
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 28, "start_col": 0, "start_line": 20 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> _: Prims.squash p -> Prims.squash (PulseCore.InstantiatedSemantics.pure p == PulseCore.InstantiatedSemantics.emp)
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.squash", "FStar.Calc.calc_finish", "PulseCore.InstantiatedSemantics.slprop", "Prims.eq2", "PulseCore.InstantiatedSemantics.pure", "PulseCore.InstantiatedSemantics.emp", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.l_True", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "PulseCore.Atomic.equiv", "PulseCore.Atomic.pure_equiv", "PulseCore.Action.pure_true" ]
[]
false
false
true
false
false
let pure_trivial (p: prop) (_: squash p) : squash (pure p == emp) =
calc ( == ) { pure p; ( == ) { equiv (pure_equiv p True ()) } pure True; ( == ) { equiv (A.pure_true ()) } emp; }
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.accessor_clens_dsum_cases_known_payload
val accessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (accessor (gaccessor_clens_dsum_cases_known_payload t f g k))
val accessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (accessor (gaccessor_clens_dsum_cases_known_payload t f g k))
let accessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (accessor (gaccessor_clens_dsum_cases_known_payload t f g k)) = [@inline_let] let _ = synth_dsum_case_injective t (Known k); synth_dsum_case_inverse t (Known k); synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) () in accessor_ext (accessor_synth (dsnd (f k)) (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) ()) (clens_dsum_cases_payload t (Known k)) ()
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 2121, "start_col": 0, "start_line": 2105 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos #push-options "--z3rlimit 32" let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload #pop-options let valid_dsum_elim_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Unknown? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid g h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload inline_for_extraction let jump_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = jumper (parse_dsum_cases' s f g x) let jump_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : jump_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let jump_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (jump_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (jump_dsum_cases_t s f g x))) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: jump_dsum_cases_t s f g x) input len else (iff () <: jump_dsum_cases_t s f g x) input len inline_for_extraction let jump_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (jump_dsum_cases_eq s f g x)) = jump_dsum_cases_if' s f g x inline_for_extraction let jump_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = synth_dsum_case_injective s x; match x with | Known x' -> jump_synth (f' x') (synth_dsum_case s (Known x')) () <: jumper (parse_dsum_cases' s f g x) | Unknown x' -> jump_synth g' (synth_dsum_case s (Unknown x')) () <: jumper (parse_dsum_cases' s f g x) inline_for_extraction let jump_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> jump_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> jump_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> jump_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let jump_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jumper (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input pos; valid_facts (parse_dsum_cases s f g x) h input pos; parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input pos) in jump_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 16" inline_for_extraction let jump_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (jumper (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: jumper g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (jump_dsum_cases_t t f g)) : Tot (jumper (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input pos) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input pos in [@inline_let] let _ = valid_facts p h input pos in let pos_after_tag = v input pos in let tg = p32 input pos in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input pos_after_tag in destr (jump_dsum_cases_eq t f g) (jump_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options inline_for_extraction let read_dsum_cases' (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #rrel #rel input pos -> [@inline_let] let _ = synth_dsum_case_injective t x in match x with | Known x' -> read_synth' (dsnd (f x')) (synth_dsum_case t (Known x')) (f32 x') () input pos | Unknown x' -> read_synth' g (synth_dsum_case t (Unknown x')) g32 () input pos inline_for_extraction let read_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot Type = leaf_reader (parse_dsum_cases' t f g (Known k)) let read_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) (x y : read_dsum_cases_t t f g k) : GTot Type0 = True inline_for_extraction let read_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (if_combinator _ (read_dsum_cases_t_eq t f g k)) = fun cond (sv_true: cond_true cond -> Tot (read_dsum_cases_t t f g k)) (sv_false: cond_false cond -> Tot (read_dsum_cases_t t f g k)) #_ #_ input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let read_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #_ #_ input pos -> match x with | Known k -> destr _ (read_dsum_cases_t_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> read_dsum_cases' t f f32 g g32 (Known k)) k input pos | Unknown r -> read_dsum_cases' t f f32 g g32 (Unknown r) input pos #push-options "--z3rlimit 16" inline_for_extraction let read_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader (parse_maybe_enum_key p (dsum_enum t))) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) : Tot (leaf_reader (parse_dsum t p f g)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_maybe_enum_key j (dsum_enum t) input pos in valid_facts (parse_dsum_cases' t f g k) h input pos' ; read_dsum_cases t f f32 g g32 destr k input pos' #pop-options inline_for_extraction let serialize32_dsum_type_of_tag (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_type_of_tag t f sf g sg tg)) = match tg with | Known x' -> serialize32_ext (dsnd (f x')) (sf x') (sf32 x') (parse_dsum_type_of_tag t f g tg) () | Unknown x' -> serialize32_ext g sg sg32 (parse_dsum_type_of_tag t f g tg) () inline_for_extraction let serialize32_dsum_cases_aux (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = [@inline_let] let _ = synth_dsum_case_injective t tg in [@inline_let] let _ = synth_dsum_case_inverse t tg in serialize32_synth (serialize32_dsum_type_of_tag t f sf sf32 sg32 tg) (synth_dsum_case t tg) (synth_dsum_case_recip t tg) (fun x -> synth_dsum_case_recip t tg x) () inline_for_extraction let serialize32_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot Type = serializer32 (serialize_dsum_cases t f sf g sg (Known k)) let serialize32_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) (x y: serialize32_dsum_cases_t t f sf g sg k) : GTot Type0 = True inline_for_extraction let serialize32_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot (if_combinator _ (serialize32_dsum_cases_t_eq t f sf g sg k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) (sv_false: (cond_false cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) x #rrel #rel output pos -> if cond then (sv_true () x output pos) else (sv_false () x output pos) inline_for_extraction let serialize32_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = fun x #rrel #rel output pos -> match tg with | Known k -> destr _ (serialize32_dsum_cases_t_if t f sf g sg) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Known k)) k x output pos | Unknown r -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Unknown r) x output pos inline_for_extraction let serialize32_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_maybe_enum_key _ s (dsum_enum t))) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) : Tot (serializer32 (serialize_dsum t s f sf g sg)) = fun x #_ #_ output pos -> [@inline_let] let _ = serialize_dsum_eq' t s f sf g sg x in let tg = dsum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_dsum_cases t f sf sf32 sg32 destr tg) tg x output pos let clens_dsum_tag (s: dsum) : Tot (clens (dsum_type s) (dsum_key s)) = { clens_cond = (fun _ -> True); clens_get = dsum_tag_of_data s; } let gaccessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) (parse_maybe_enum_key p (dsum_enum t)) (clens_dsum_tag t)) = gaccessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) inline_for_extraction let accessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_dsum_tag t p f g)) = accessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) let clens_dsum_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_type s) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_type s) -> dsum_tag_of_data s x == k); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (dsum_tag_of_data s x == k)) (ensures (fun _ -> True))); } let clens_dsum_unknown_payload (s: dsum) : Tot (clens (dsum_type s) (dsum_type_of_unknown_tag s)) = { clens_cond = (fun (x: dsum_type s) -> Unknown? (dsum_tag_of_data s x)); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s (dsum_tag_of_data s x) x <: Ghost (dsum_type_of_unknown_tag s) (requires (Unknown? (dsum_tag_of_data s x))) (ensures (fun _ -> True))); } #push-options "--z3rlimit 16" let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res } )) let gaccessor_clens_dsum_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_injective t p f g k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_no_lookahead t p f g k x)); gaccessor_prop_equiv (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) (gaccessor_clens_dsum_payload' t p f g k); gaccessor_clens_dsum_payload' t p f g k inline_for_extraction let accessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_payload t k).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_payload t p f g k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_payload t p f g k) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (accessor (gaccessor_clens_dsum_payload t p f g k)) = fun #rrel #rel -> accessor_clens_dsum_payload' t j f g k #rrel #rel #push-options "--z3rlimit 16" let gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (tg, consumed) -> let k = maybe_enum_key_of_repr (dsum_enum t) tg in synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) g (clens_dsum_unknown_payload t) input res } )) let gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_unknown_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_unknown_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_unknown_payload_injective t p f g x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_unknown_payload_no_lookahead t p f g x)); gaccessor_prop_equiv (parse_dsum t p f g) g (clens_dsum_unknown_payload t) (gaccessor_clens_dsum_unknown_payload' t p f g); gaccessor_clens_dsum_unknown_payload' t p f g inline_for_extraction let accessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_unknown_payload t).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_unknown_payload t p f g) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_unknown_payload t p f g) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_unknown_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p { kt.parser_kind_subkind == Some ParserStrong }) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_clens_dsum_unknown_payload t p f g)) = fun #rrel #rel -> accessor_clens_dsum_unknown_payload' t j f g #rrel #rel let clens_dsum_cases_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_cases s k) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_cases s k) -> True); clens_get = (fun (x: dsum_cases s k) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (gaccessor (parse_dsum_cases' t f g (Known k)) (dsnd (f k)) (clens_dsum_cases_payload t (Known k))) = synth_dsum_case_injective t (Known k); synth_dsum_case_inverse t (Known k); synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) (); gaccessor_ext (gaccessor_synth (dsnd (f k)) (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) ()) (clens_dsum_cases_payload t (Known k)) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.dsum -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> k: LowParse.Spec.Sum.dsum_known_key t -> LowParse.Low.Base.accessor (LowParse.Low.Sum.gaccessor_clens_dsum_cases_known_payload t f g k)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Sum.dsum", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Low.Base.accessor_ext", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Sum.dsum_cases", "LowParse.Spec.Enum.Known", "LowParse.Spec.Sum.dsum_key_type", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_enum", "LowParse.Spec.Combinators.parse_synth", "FStar.Pervasives.dsnd", "LowParse.Spec.Sum.synth_dsum_case", "LowParse.Low.Combinators.clens_synth", "LowParse.Spec.Sum.synth_dsum_case_recip", "LowParse.Low.Combinators.gaccessor_synth", "LowParse.Low.Combinators.accessor_synth", "LowParse.Low.Sum.clens_dsum_cases_payload", "Prims.squash", "LowParse.Spec.Combinators.synth_inverse", "LowParse.Spec.Base.refine_with_tag", "LowParse.Spec.Sum.dsum_key", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.dsum_tag_of_data", "LowParse.Spec.Sum.dsum_type_of_tag", "LowParse.Spec.Combinators.synth_injective_synth_inverse_synth_inverse_recip", "Prims.unit", "LowParse.Spec.Sum.synth_dsum_case_inverse", "LowParse.Spec.Sum.synth_dsum_case_injective", "LowParse.Low.Base.accessor", "LowParse.Spec.Sum.parse_dsum_cases_kind", "LowParse.Spec.Sum.parse_dsum_cases'", "LowParse.Low.Sum.gaccessor_clens_dsum_cases_known_payload" ]
[]
false
false
false
false
false
let accessor_clens_dsum_cases_known_payload (t: dsum) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (accessor (gaccessor_clens_dsum_cases_known_payload t f g k)) =
[@@ inline_let ]let _ = synth_dsum_case_injective t (Known k); synth_dsum_case_inverse t (Known k); synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) () in accessor_ext (accessor_synth (dsnd (f k)) (synth_dsum_case t (Known k)) (synth_dsum_case_recip t (Known k)) ()) (clens_dsum_cases_payload t (Known k)) ()
false
PulseCore.Atomic.fst
PulseCore.Atomic.stt_ghost
val stt_ghost (a:Type u#a) (pre:slprop) (post:a -> slprop) : Type u#(max 2 a)
val stt_ghost (a:Type u#a) (pre:slprop) (post:a -> slprop) : Type u#(max 2 a)
let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 145, "start_col": 0, "start_line": 145 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> pre: PulseCore.InstantiatedSemantics.slprop -> post: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> Type
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.erased", "PulseCore.Action.act", "PulseCore.Action.emp_inames" ]
[]
false
false
false
true
true
let stt_ghost a pre post =
Ghost.erased (act a emp_inames pre post)
false
PulseCore.Atomic.fst
PulseCore.Atomic.return_ghost
val return_ghost (#a:Type u#a) (x:a) (p:a -> slprop) : stt_ghost a (p x) (fun r -> p r ** pure (r == x))
val return_ghost (#a:Type u#a) (x:a) (p:a -> slprop) : stt_ghost a (p x) (fun r -> p r ** pure (r == x))
let return_ghost #a x p = Ghost.hide (return_atomic #a x p)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 59, "end_line": 146, "start_col": 0, "start_line": 146 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> p: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> PulseCore.Atomic.stt_ghost a (p x) (fun r -> p r ** PulseCore.InstantiatedSemantics.pure (r == x))
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.pure", "Prims.eq2", "PulseCore.Atomic.return_atomic", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let return_ghost #a x p =
Ghost.hide (return_atomic #a x p)
false
PulseCore.Atomic.fst
PulseCore.Atomic.bind_ghost
val bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2
val bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2
let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 27, "end_line": 159, "start_col": 0, "start_line": 148 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: PulseCore.Atomic.stt_ghost a pre1 post1 -> e2: (x: a -> PulseCore.Atomic.stt_ghost b (post1 x) post2) -> PulseCore.Atomic.stt_ghost b pre1 post2
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_ghost", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.Action.bind", "FStar.Ghost.Pull.pull", "FStar.Ghost.reveal" ]
[]
false
false
false
false
false
let bind_ghost (#a: Type u#a) (#b: Type u#b) (#pre1: slprop) (#post1: (a -> slprop)) (#post2: (b -> slprop)) (e1: stt_ghost a pre1 post1) (e2: (x: a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 =
let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x: a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2)
false
PulseCore.Atomic.fst
PulseCore.Atomic.return_ghost_noeq
val return_ghost_noeq (#a:Type u#a) (x:a) (p:a -> slprop) : stt_ghost a (p x) p
val return_ghost_noeq (#a:Type u#a) (x:a) (p:a -> slprop) : stt_ghost a (p x) p
let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 60, "end_line": 147, "start_col": 0, "start_line": 147 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> p: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> PulseCore.Atomic.stt_ghost a (p x) p
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.Action.return", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let return_ghost_noeq #a x p =
Ghost.hide (A.return #_ #p x)
false
PulseCore.Atomic.fst
PulseCore.Atomic.intro_pure
val intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p)
val intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p)
let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 196, "start_col": 0, "start_line": 194 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ())
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> pf: Prims.squash p -> PulseCore.Atomic.stt_ghost Prims.unit PulseCore.InstantiatedSemantics.emp (fun _ -> PulseCore.InstantiatedSemantics.pure p)
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "Prims.squash", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.emp", "PulseCore.InstantiatedSemantics.pure", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.intro_pure", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let intro_pure (p: prop) (pf: squash p) : stt_ghost unit emp (fun _ -> pure p) =
Ghost.hide (A.intro_pure p pf)
false
PulseCore.Atomic.fst
PulseCore.Atomic.noop
val noop (p:slprop) : stt_ghost unit p (fun _ -> p)
val noop (p:slprop) : stt_ghost unit p (fun _ -> p)
let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ())
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 192, "start_col": 0, "start_line": 190 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: PulseCore.InstantiatedSemantics.slprop -> PulseCore.Atomic.stt_ghost Prims.unit p (fun _ -> p)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "PulseCore.Action.return", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let noop (p: slprop) : stt_ghost unit p (fun _ -> p) =
Ghost.hide (A.return #_ #(fun _ -> p) ())
false
PulseCore.Atomic.fst
PulseCore.Atomic.frame_ghost
val frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame)
val frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame)
let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e))
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 185, "start_col": 0, "start_line": 178 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
frame: PulseCore.InstantiatedSemantics.slprop -> e: PulseCore.Atomic.stt_ghost a pre post -> PulseCore.Atomic.stt_ghost a (pre ** frame) (fun x -> post x ** frame)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_ghost", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.Action.frame", "FStar.Ghost.reveal" ]
[]
false
false
false
false
false
let frame_ghost (#a: Type u#a) (#pre: slprop) (#post: (a -> slprop)) (frame: slprop) (e: stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) =
Ghost.hide (A.frame (Ghost.reveal e))
false
PulseCore.Atomic.fst
PulseCore.Atomic.lift_neutral_ghost
val lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post
val lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post
let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 176, "start_col": 0, "start_line": 170 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: PulseCore.Atomic.stt_atomic a PulseCore.Action.emp_inames pre post -> PulseCore.Atomic.stt_ghost a pre post
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_atomic", "PulseCore.Observability.Neutral", "PulseCore.Action.emp_inames", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let lift_neutral_ghost (#a: Type u#a) (#pre: slprop) (#post: (a -> slprop)) (e: stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post =
Ghost.hide e
false
PulseCore.Atomic.fst
PulseCore.Atomic.intro_exists
val intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x)
val intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x)
let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 204, "start_col": 0, "start_line": 202 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> x: FStar.Ghost.erased a -> PulseCore.Atomic.stt_ghost Prims.unit (p (FStar.Ghost.reveal x)) (fun _ -> exists* (x: a). p x)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.erased", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "FStar.Ghost.reveal", "PulseCore.InstantiatedSemantics.op_exists_Star", "PulseCore.Action.intro_exists", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let intro_exists (#a: Type u#a) (p: (a -> slprop)) (x: erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) =
Ghost.hide (A.intro_exists p x)
false
PulseCore.Atomic.fst
PulseCore.Atomic.elim_pure
val elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp)
val elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp)
let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 200, "start_col": 0, "start_line": 198 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.prop -> PulseCore.Atomic.stt_ghost (Prims.squash p) (PulseCore.InstantiatedSemantics.pure p) (fun _ -> PulseCore.InstantiatedSemantics.emp)
Prims.Tot
[ "total" ]
[]
[ "Prims.prop", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.squash", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.pure", "PulseCore.InstantiatedSemantics.emp", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.elim_pure", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let elim_pure (p: prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) =
Ghost.hide (A.elim_pure p)
false
PulseCore.Atomic.fst
PulseCore.Atomic.elim_exists
val elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x)
val elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x)
let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 208, "start_col": 0, "start_line": 206 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> PulseCore.Atomic.stt_ghost (FStar.Ghost.erased a) (exists* (x: a). p x) (fun x -> p (FStar.Ghost.reveal x))
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "FStar.Ghost.erased", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.op_exists_Star", "FStar.Ghost.reveal", "PulseCore.Action.elim_exists", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let elim_exists (#a: Type u#a) (p: (a -> slprop)) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) =
Ghost.hide (A.elim_exists p)
false
PulseCore.Atomic.fst
PulseCore.Atomic.sub_atomic
val sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2
val sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2
let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 131, "start_col": 0, "start_line": 119 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pre2: PulseCore.InstantiatedSemantics.slprop -> post2: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> pf1: PulseCore.InstantiatedSemantics.slprop_equiv pre1 pre2 -> pf2: PulseCore.InstantiatedSemantics.slprop_post_equiv post1 post2 -> e: PulseCore.Atomic.stt_atomic a opens pre1 post1 -> PulseCore.Atomic.stt_atomic a opens pre2 post2
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "PulseCore.Action.inames", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.InstantiatedSemantics.slprop_equiv", "PulseCore.InstantiatedSemantics.slprop_post_equiv", "PulseCore.Atomic.stt_atomic", "PulseCore.Action.sub" ]
[]
false
false
false
false
false
let sub_atomic (#a: Type u#a) (#obs: _) (#opens: inames) (#pre1 pre2: slprop) (#post1 post2: (a -> slprop)) (pf1: slprop_equiv pre1 pre2) (pf2: slprop_post_equiv post1 post2) (e: stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 =
A.sub pre2 post2 e
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.valid_sum_elim
val valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_sum t p pc) h input pos)) (ensures (valid p h input pos /\ (let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False)))
val valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_sum t p pc) h input pos)) (ensures (valid p h input pos /\ (let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False)))
let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> ()
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 11, "end_line": 477, "start_col": 0, "start_line": 440 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> t: LowParse.Spec.Sum.sum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.sum_repr_type t) -> pc: (x: LowParse.Spec.Sum.sum_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.sum_type_of_tag t x))) -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.Sum.parse_sum t p pc) h input pos) (ensures LowParse.Low.Base.Spec.valid p h input pos /\ (let pos_payload = LowParse.Low.Base.Spec.get_valid_pos p h input pos in let k' = LowParse.Spec.Enum.maybe_enum_key_of_repr (LowParse.Spec.Sum.sum_enum t) (LowParse.Low.Base.Spec.contents p h input pos) in (match k' with | LowParse.Spec.Enum.Known #_ #_ #_ k -> k == LowParse.Spec.Sum.sum_tag_of_data t (LowParse.Low.Base.Spec.contents (LowParse.Spec.Sum.parse_sum t p pc) h input pos) /\ LowParse.Low.Base.Spec.valid (FStar.Pervasives.dsnd (pc k)) h input pos_payload /\ LowParse.Low.Base.Spec.valid_pos (LowParse.Spec.Sum.parse_sum t p pc) h input pos (LowParse.Low.Base.Spec.get_valid_pos (FStar.Pervasives.dsnd (pc k)) h input pos_payload) | _ -> Prims.l_False) <: Prims.logical))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Spec.Sum.sum", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.sum_repr_type", "LowParse.Spec.Sum.sum_key", "Prims.dtuple2", "LowParse.Spec.Sum.sum_type_of_tag", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Enum.maybe_enum_key_of_repr", "LowParse.Spec.Sum.sum_key_type", "LowParse.Spec.Sum.sum_enum", "LowParse.Spec.Enum.enum_key", "LowParse.Low.Base.Spec.valid_facts", "Prims.__proj__Mkdtuple2__item___1", "FStar.Pervasives.dsnd", "LowParse.Spec.Enum.maybe_enum_key", "Prims.unit", "Prims._assert", "LowParse.Low.Base.Spec.valid_content_pos", "FStar.UInt32.uint_to_t", "Prims.op_Addition", "FStar.UInt32.v", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.parse", "LowParse.Spec.Sum.parse_sum_kind", "LowParse.Spec.Sum.sum_type", "LowParse.Spec.Sum.parse_sum", "LowParse.Spec.Sum.parse_sum_eq''", "LowParse.Bytes.bytes", "LowParse.Slice.bytes_of_slice_from", "LowParse.Low.Base.Spec.valid", "Prims.squash", "Prims.l_and", "Prims.eq2", "LowParse.Spec.Sum.sum_tag_of_data", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.Spec.valid_pos", "LowParse.Low.Base.Spec.get_valid_pos", "Prims.l_False", "Prims.logical", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_sum t p pc) h input pos)) (ensures (valid p h input pos /\ (let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False))) =
let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@@ inline_let ]let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@@ inline_let ]let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> ()
false
PulseCore.Atomic.fst
PulseCore.Atomic.new_invariant
val new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp)
val new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp)
let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 224, "start_col": 0, "start_line": 221 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: PulseCore.InstantiatedSemantics.slprop -> PulseCore.Atomic.stt_atomic (PulseCore.Action.inv p) PulseCore.Action.emp_inames p (fun _ -> PulseCore.InstantiatedSemantics.emp)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.new_invariant", "PulseCore.Atomic.stt_atomic", "PulseCore.Action.inv", "PulseCore.Observability.Unobservable", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.emp" ]
[]
false
false
false
false
false
let new_invariant (p: slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) =
A.new_invariant p
false
PulseCore.Atomic.fst
PulseCore.Atomic.with_invariant
val with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #(join_obs obs Unobservable) (add_inv f_opens i) fp fp'
val with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #(join_obs obs Unobservable) (add_inv f_opens i) fp fp'
let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 22, "end_line": 238, "start_col": 0, "start_line": 226 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: PulseCore.Action.inv p {Prims.op_Negation (PulseCore.Action.mem_inv f_opens i)} -> $f: (_: Prims.unit -> PulseCore.Atomic.stt_atomic a f_opens (p ** fp) (fun x -> p ** fp' x)) -> PulseCore.Atomic.stt_atomic a (PulseCore.Action.add_inv f_opens i) fp fp'
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.inames", "PulseCore.Action.inv", "Prims.b2t", "Prims.op_Negation", "PulseCore.Action.mem_inv", "Prims.unit", "PulseCore.Atomic.stt_atomic", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.Action.with_invariant", "PulseCore.Action.add_inv", "PulseCore.Observability.join_obs", "PulseCore.Observability.Unobservable" ]
[]
false
false
false
false
false
let with_invariant (#a: Type) (#obs: _) (#fp: slprop) (#fp': (a -> slprop)) (#f_opens: inames) (#p: slprop) (i: inv p {not (mem_inv f_opens i)}) ($f: (unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x))) : stt_atomic a #obs (add_inv f_opens i) fp fp' =
A.with_invariant i f
false
PulseCore.Atomic.fst
PulseCore.Atomic.pts_to_not_null
val pts_to_not_null (#a:Type u#1) (#p:FStar.PCM.pcm a) (r:ref a p) (v:a) : stt_ghost (squash (not (is_ref_null r))) (pts_to r v) (fun _ -> pts_to r v)
val pts_to_not_null (#a:Type u#1) (#p:FStar.PCM.pcm a) (r:ref a p) (v:a) : stt_ghost (squash (not (is_ref_null r))) (pts_to r v) (fun _ -> pts_to r v)
let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 72, "end_line": 240, "start_col": 0, "start_line": 240 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Action.ref a p -> v: a -> PulseCore.Atomic.stt_ghost (Prims.squash (Prims.op_Negation (PulseCore.Action.is_ref_null r))) (PulseCore.Action.pts_to r v) (fun _ -> PulseCore.Action.pts_to r v)
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Action.ref", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.squash", "Prims.b2t", "Prims.op_Negation", "PulseCore.Action.is_ref_null", "PulseCore.Action.emp_inames", "PulseCore.Action.pts_to", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.pts_to_not_null", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let pts_to_not_null #a #p r v =
Ghost.hide (A.pts_to_not_null #a #p r v)
false
PulseCore.Atomic.fst
PulseCore.Atomic.alloc
val alloc (#a:Type u#1) (#pcm:pcm a) (x:a{compatible pcm x x /\ pcm.refine x}) : stt_atomic (ref a pcm) #Observable emp_inames emp (fun r -> pts_to r x)
val alloc (#a:Type u#1) (#pcm:pcm a) (x:a{compatible pcm x x /\ pcm.refine x}) : stt_atomic (ref a pcm) #Observable emp_inames emp (fun r -> pts_to r x)
let alloc = A.alloc
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 241, "start_col": 0, "start_line": 241 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a{FStar.PCM.compatible pcm x x /\ Mkpcm?.refine pcm x} -> PulseCore.Atomic.stt_atomic (PulseCore.Action.ref a pcm) PulseCore.Action.emp_inames PulseCore.InstantiatedSemantics.emp (fun r -> PulseCore.Action.pts_to r x)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Action.alloc" ]
[]
false
false
false
false
false
let alloc =
A.alloc
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload_injective
val gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl')) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl'))
val gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl')) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl'))
let gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl'
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 1995, "start_col": 0, "start_line": 1977 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos #push-options "--z3rlimit 32" let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload #pop-options let valid_dsum_elim_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Unknown? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid g h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload inline_for_extraction let jump_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = jumper (parse_dsum_cases' s f g x) let jump_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : jump_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let jump_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (jump_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (jump_dsum_cases_t s f g x))) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: jump_dsum_cases_t s f g x) input len else (iff () <: jump_dsum_cases_t s f g x) input len inline_for_extraction let jump_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (jump_dsum_cases_eq s f g x)) = jump_dsum_cases_if' s f g x inline_for_extraction let jump_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = synth_dsum_case_injective s x; match x with | Known x' -> jump_synth (f' x') (synth_dsum_case s (Known x')) () <: jumper (parse_dsum_cases' s f g x) | Unknown x' -> jump_synth g' (synth_dsum_case s (Unknown x')) () <: jumper (parse_dsum_cases' s f g x) inline_for_extraction let jump_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> jump_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> jump_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> jump_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let jump_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jumper (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input pos; valid_facts (parse_dsum_cases s f g x) h input pos; parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input pos) in jump_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 16" inline_for_extraction let jump_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (jumper (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: jumper g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (jump_dsum_cases_t t f g)) : Tot (jumper (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input pos) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input pos in [@inline_let] let _ = valid_facts p h input pos in let pos_after_tag = v input pos in let tg = p32 input pos in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input pos_after_tag in destr (jump_dsum_cases_eq t f g) (jump_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options inline_for_extraction let read_dsum_cases' (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #rrel #rel input pos -> [@inline_let] let _ = synth_dsum_case_injective t x in match x with | Known x' -> read_synth' (dsnd (f x')) (synth_dsum_case t (Known x')) (f32 x') () input pos | Unknown x' -> read_synth' g (synth_dsum_case t (Unknown x')) g32 () input pos inline_for_extraction let read_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot Type = leaf_reader (parse_dsum_cases' t f g (Known k)) let read_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) (x y : read_dsum_cases_t t f g k) : GTot Type0 = True inline_for_extraction let read_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (if_combinator _ (read_dsum_cases_t_eq t f g k)) = fun cond (sv_true: cond_true cond -> Tot (read_dsum_cases_t t f g k)) (sv_false: cond_false cond -> Tot (read_dsum_cases_t t f g k)) #_ #_ input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let read_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #_ #_ input pos -> match x with | Known k -> destr _ (read_dsum_cases_t_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> read_dsum_cases' t f f32 g g32 (Known k)) k input pos | Unknown r -> read_dsum_cases' t f f32 g g32 (Unknown r) input pos #push-options "--z3rlimit 16" inline_for_extraction let read_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader (parse_maybe_enum_key p (dsum_enum t))) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) : Tot (leaf_reader (parse_dsum t p f g)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_maybe_enum_key j (dsum_enum t) input pos in valid_facts (parse_dsum_cases' t f g k) h input pos' ; read_dsum_cases t f f32 g g32 destr k input pos' #pop-options inline_for_extraction let serialize32_dsum_type_of_tag (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_type_of_tag t f sf g sg tg)) = match tg with | Known x' -> serialize32_ext (dsnd (f x')) (sf x') (sf32 x') (parse_dsum_type_of_tag t f g tg) () | Unknown x' -> serialize32_ext g sg sg32 (parse_dsum_type_of_tag t f g tg) () inline_for_extraction let serialize32_dsum_cases_aux (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = [@inline_let] let _ = synth_dsum_case_injective t tg in [@inline_let] let _ = synth_dsum_case_inverse t tg in serialize32_synth (serialize32_dsum_type_of_tag t f sf sf32 sg32 tg) (synth_dsum_case t tg) (synth_dsum_case_recip t tg) (fun x -> synth_dsum_case_recip t tg x) () inline_for_extraction let serialize32_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot Type = serializer32 (serialize_dsum_cases t f sf g sg (Known k)) let serialize32_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) (x y: serialize32_dsum_cases_t t f sf g sg k) : GTot Type0 = True inline_for_extraction let serialize32_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot (if_combinator _ (serialize32_dsum_cases_t_eq t f sf g sg k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) (sv_false: (cond_false cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) x #rrel #rel output pos -> if cond then (sv_true () x output pos) else (sv_false () x output pos) inline_for_extraction let serialize32_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = fun x #rrel #rel output pos -> match tg with | Known k -> destr _ (serialize32_dsum_cases_t_if t f sf g sg) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Known k)) k x output pos | Unknown r -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Unknown r) x output pos inline_for_extraction let serialize32_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_maybe_enum_key _ s (dsum_enum t))) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) : Tot (serializer32 (serialize_dsum t s f sf g sg)) = fun x #_ #_ output pos -> [@inline_let] let _ = serialize_dsum_eq' t s f sf g sg x in let tg = dsum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_dsum_cases t f sf sf32 sg32 destr tg) tg x output pos let clens_dsum_tag (s: dsum) : Tot (clens (dsum_type s) (dsum_key s)) = { clens_cond = (fun _ -> True); clens_get = dsum_tag_of_data s; } let gaccessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) (parse_maybe_enum_key p (dsum_enum t)) (clens_dsum_tag t)) = gaccessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) inline_for_extraction let accessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_dsum_tag t p f g)) = accessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) let clens_dsum_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_type s) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_type s) -> dsum_tag_of_data s x == k); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (dsum_tag_of_data s x == k)) (ensures (fun _ -> True))); } let clens_dsum_unknown_payload (s: dsum) : Tot (clens (dsum_type s) (dsum_type_of_unknown_tag s)) = { clens_cond = (fun (x: dsum_type s) -> Unknown? (dsum_tag_of_data s x)); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s (dsum_tag_of_data s x) x <: Ghost (dsum_type_of_unknown_tag s) (requires (Unknown? (dsum_tag_of_data s x))) (ensures (fun _ -> True))); } #push-options "--z3rlimit 16" let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res } )) let gaccessor_clens_dsum_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_injective t p f g k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_no_lookahead t p f g k x)); gaccessor_prop_equiv (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) (gaccessor_clens_dsum_payload' t p f g k); gaccessor_clens_dsum_payload' t p f g k inline_for_extraction let accessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_payload t k).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_payload t p f g k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_payload t p f g k) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (accessor (gaccessor_clens_dsum_payload t p f g k)) = fun #rrel #rel -> accessor_clens_dsum_payload' t j f g k #rrel #rel #push-options "--z3rlimit 16" let gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (tg, consumed) -> let k = maybe_enum_key_of_repr (dsum_enum t) tg in synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) g (clens_dsum_unknown_payload t) input res } ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.dsum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.dsum_repr_type t) -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> sl: LowParse.Bytes.bytes -> sl': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.Sum.parse_dsum t p f g) g (LowParse.Low.Sum.clens_dsum_unknown_payload t) sl /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.Sum.parse_dsum t p f g) g (LowParse.Low.Sum.clens_dsum_unknown_payload t) sl' /\ LowParse.Spec.Base.injective_precond (LowParse.Spec.Sum.parse_dsum t p f g) sl sl') (ensures LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload' t p f g sl == LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload' t p f g sl')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Sum.dsum", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse_injective", "Prims.unit", "LowParse.Spec.Sum.parse_dsum_kind", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.parse_dsum", "LowParse.Spec.Sum.parse_dsum_eq3", "Prims.l_and", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Low.Sum.clens_dsum_unknown_payload", "LowParse.Spec.Base.injective_precond", "Prims.squash", "Prims.eq2", "Prims.nat", "LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl')) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) =
parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl'; parse_injective p sl sl'
false
PulseCore.Atomic.fst
PulseCore.Atomic.sub_invs_stt_atomic
val sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post
val sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post
let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 143, "start_col": 0, "start_line": 133 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: PulseCore.Atomic.stt_atomic a opens1 pre post -> _: Prims.squash (PulseCore.Action.inames_subset opens1 opens2) -> PulseCore.Atomic.stt_atomic a opens2 pre post
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "PulseCore.Action.inames", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_atomic", "Prims.squash", "PulseCore.Action.inames_subset", "PulseCore.Action.weaken", "Prims.unit", "Prims._assert", "FStar.Set.equal", "PulseCore.Action.iname", "FStar.Set.union", "FStar.Ghost.reveal", "FStar.Set.set" ]
[]
false
false
false
false
false
let sub_invs_stt_atomic (#a: Type u#a) (#obs: _) (#opens1: inames) (#opens2: inames) (#pre: slprop) (#post: (a -> slprop)) (e: stt_atomic a #obs opens1 pre post) (_: squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post =
assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e
false
PulseCore.Atomic.fst
PulseCore.Atomic.witness
val witness (#a:Type) (#pcm:pcm a) (r:erased (ref a pcm)) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) : stt_ghost (witnessed r fact) (pts_to r v) (fun _ -> pts_to r v)
val witness (#a:Type) (#pcm:pcm a) (r:erased (ref a pcm)) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) : stt_ghost (witnessed r fact) (pts_to r v) (fun _ -> pts_to r v)
let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 246, "start_col": 0, "start_line": 246 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Ghost.erased (PulseCore.Action.ref a pcm) -> fact: PulseCore.Action.stable_property pcm -> v: FStar.Ghost.erased a -> pf: Prims.squash (forall (z: a). FStar.PCM.compatible pcm (FStar.Ghost.reveal v) z ==> fact z) -> PulseCore.Atomic.stt_ghost (PulseCore.Action.witnessed (FStar.Ghost.reveal r) fact) (PulseCore.Action.pts_to (FStar.Ghost.reveal r) (FStar.Ghost.reveal v)) (fun _ -> PulseCore.Action.pts_to (FStar.Ghost.reveal r) (FStar.Ghost.reveal v))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "FStar.Ghost.erased", "PulseCore.Action.ref", "PulseCore.Action.stable_property", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "FStar.PCM.compatible", "FStar.Ghost.reveal", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.witnessed", "PulseCore.Action.emp_inames", "PulseCore.Action.pts_to", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.witness", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let witness #a #pcm r f v pf =
Ghost.hide (A.witness r f v pf)
false
PulseCore.Atomic.fst
PulseCore.Atomic.write
val write (#a:Type) (#p:pcm a) (r:ref a p) (x y:Ghost.erased a) (f:FStar.PCM.frame_preserving_upd p x y) : stt_atomic unit #Observable emp_inames (pts_to r x) (fun _ -> pts_to r y)
val write (#a:Type) (#p:pcm a) (r:ref a p) (x y:Ghost.erased a) (f:FStar.PCM.frame_preserving_upd p x y) : stt_atomic unit #Observable emp_inames (pts_to r x) (fun _ -> pts_to r y)
let write = A.write
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 243, "start_col": 0, "start_line": 243 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Action.ref a p -> x: FStar.Ghost.erased a -> y: FStar.Ghost.erased a -> f: FStar.PCM.frame_preserving_upd p (FStar.Ghost.reveal x) (FStar.Ghost.reveal y) -> PulseCore.Atomic.stt_atomic Prims.unit PulseCore.Action.emp_inames (PulseCore.Action.pts_to r (FStar.Ghost.reveal x)) (fun _ -> PulseCore.Action.pts_to r (FStar.Ghost.reveal y))
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Action.write" ]
[]
false
false
false
false
false
let write =
A.write
false
PulseCore.Atomic.fst
PulseCore.Atomic.recall
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a) (r:erased (ref a pcm)) (v:Ghost.erased a) (w:witnessed r fact) : stt_ghost (v1:Ghost.erased a{compatible pcm v v1}) (pts_to r v) (fun v1 -> pts_to r v ** pure (fact v1))
val recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a) (r:erased (ref a pcm)) (v:Ghost.erased a) (w:witnessed r fact) : stt_ghost (v1:Ghost.erased a{compatible pcm v v1}) (pts_to r v) (fun v1 -> pts_to r v ** pure (fact v1))
let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 60, "end_line": 247, "start_col": 0, "start_line": 247 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Ghost.erased (PulseCore.Action.ref a pcm) -> v: FStar.Ghost.erased a -> w: PulseCore.Action.witnessed (FStar.Ghost.reveal r) fact -> PulseCore.Atomic.stt_ghost (v1: FStar.Ghost.erased a {FStar.PCM.compatible pcm (FStar.Ghost.reveal v) (FStar.Ghost.reveal v1)}) (PulseCore.Action.pts_to (FStar.Ghost.reveal r) (FStar.Ghost.reveal v)) (fun v1 -> PulseCore.Action.pts_to (FStar.Ghost.reveal r) (FStar.Ghost.reveal v) ** PulseCore.InstantiatedSemantics.pure (fact (FStar.Ghost.reveal v1)))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Action.property", "FStar.Ghost.erased", "PulseCore.Action.ref", "PulseCore.Action.witnessed", "FStar.Ghost.reveal", "FStar.Ghost.hide", "PulseCore.Action.act", "FStar.PCM.compatible", "PulseCore.Action.emp_inames", "PulseCore.Action.pts_to", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.pure", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.recall", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let recall #a #pcm #fact r v w =
Ghost.hide (A.recall r v w)
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_pts_to
val ghost_pts_to (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (v:a) : slprop
val ghost_pts_to (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (v:a) : slprop
let ghost_pts_to #a #p r v = pts_to r v
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 250, "start_col": 0, "start_line": 250 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref p -> v: a -> PulseCore.InstantiatedSemantics.slprop
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "PulseCore.Action.pts_to", "FStar.Ghost.reveal", "PulseCore.Action.ref", "PulseCore.InstantiatedSemantics.slprop" ]
[]
false
false
false
false
false
let ghost_pts_to #a #p r v =
pts_to r v
false
PulseCore.Atomic.fst
PulseCore.Atomic.sub_ghost
val sub_ghost (#a:Type u#a) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_ghost a pre1 post1) : stt_ghost a pre2 post2
val sub_ghost (#a:Type u#a) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_ghost a pre1 post1) : stt_ghost a pre2 post2
let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 33, "end_line": 188, "start_col": 0, "start_line": 187 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e))
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pre2: PulseCore.InstantiatedSemantics.slprop -> post2: (_: a -> PulseCore.InstantiatedSemantics.slprop) -> pf1: PulseCore.InstantiatedSemantics.slprop_equiv pre1 pre2 -> pf2: PulseCore.InstantiatedSemantics.slprop_post_equiv post1 post2 -> e: PulseCore.Atomic.stt_ghost a pre1 post1 -> PulseCore.Atomic.stt_ghost a pre2 post2
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.InstantiatedSemantics.slprop_equiv", "PulseCore.InstantiatedSemantics.slprop_post_equiv", "PulseCore.Atomic.stt_ghost", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.Action.sub", "FStar.Ghost.reveal" ]
[]
false
false
false
false
false
let sub_ghost pre2 post2 pf1 pf2 e =
Ghost.hide (A.sub pre2 post2 e)
false
PulseCore.Atomic.fst
PulseCore.Atomic.hide_ghost
val hide_ghost (#a #pre #post: _) (f: stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x))
val hide_ghost (#a #pre #post: _) (f: stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x))
let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r))
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 259, "start_col": 0, "start_line": 251 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: PulseCore.Atomic.stt_ghost a pre post -> PulseCore.Atomic.stt_ghost (FStar.Ghost.erased a) pre (fun x -> post (FStar.Ghost.reveal x))
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Atomic.stt_ghost", "FStar.Ghost.hide", "PulseCore.Action.act", "FStar.Ghost.erased", "PulseCore.Action.emp_inames", "FStar.Ghost.reveal", "PulseCore.Action.bind", "PulseCore.Action.return" ]
[]
false
false
false
false
false
let hide_ghost #a #pre #post (f: stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) =
let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r: a) -> A.return #(erased a) #(fun (x: erased a) -> post (reveal x)) (hide r))
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_ref
val ghost_ref (#[@@@unused] a:Type u#a) ([@@@unused]p:pcm a) : Type0
val ghost_ref (#[@@@unused] a:Type u#a) ([@@@unused]p:pcm a) : Type0
let ghost_ref #a p = Ghost.erased (ref a p)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 249, "start_col": 0, "start_line": 249 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.PCM.pcm a -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "FStar.Ghost.erased", "PulseCore.Action.ref" ]
[]
false
false
false
true
true
let ghost_ref #a p =
Ghost.erased (ref a p)
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_witnessed
val ghost_witnessed (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (f:property a) : Type0
val ghost_witnessed (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (f:property a) : Type0
let ghost_witnessed (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (f:property a) = witnessed (reveal r) f
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 285, "start_col": 0, "start_line": 280 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f let ghost_write r x y f = Ghost.hide (A.write r x y f) let ghost_share r v0 v1 = Ghost.hide (A.share r v0 v1) let ghost_gather r v0 v1 = Ghost.hide (A.gather r v0 v1)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref p -> f: PulseCore.Action.property a -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "PulseCore.Action.property", "PulseCore.Action.witnessed", "FStar.Ghost.reveal", "PulseCore.Action.ref" ]
[]
false
false
false
false
true
let ghost_witnessed (#a: Type u#1) (#p: pcm a) (r: ghost_ref p) (f: property a) =
witnessed (reveal r) f
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_write
val ghost_write (#a:Type) (#p:pcm a) (r:ghost_ref p) (x y:Ghost.erased a) (f:FStar.PCM.frame_preserving_upd p x y) : stt_ghost unit (ghost_pts_to r x) (fun _ -> ghost_pts_to r y)
val ghost_write (#a:Type) (#p:pcm a) (r:ghost_ref p) (x y:Ghost.erased a) (f:FStar.PCM.frame_preserving_upd p x y) : stt_ghost unit (ghost_pts_to r x) (fun _ -> ghost_pts_to r y)
let ghost_write r x y f = Ghost.hide (A.write r x y f)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 275, "start_col": 0, "start_line": 275 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref p -> x: FStar.Ghost.erased a -> y: FStar.Ghost.erased a -> f: FStar.PCM.frame_preserving_upd p (FStar.Ghost.reveal x) (FStar.Ghost.reveal y) -> PulseCore.Atomic.stt_ghost Prims.unit (PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal x)) (fun _ -> PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal y))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "FStar.Ghost.erased", "FStar.PCM.frame_preserving_upd", "FStar.Ghost.reveal", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "PulseCore.Atomic.ghost_pts_to", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.write", "PulseCore.Action.ref", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let ghost_write r x y f =
Ghost.hide (A.write r x y f)
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_reveal
val ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y))
val ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y))
let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 219, "start_col": 0, "start_line": 210 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: FStar.Ghost.erased a -> PulseCore.Atomic.stt_ghost a PulseCore.InstantiatedSemantics.emp (fun y -> PulseCore.InstantiatedSemantics.pure (FStar.Ghost.reveal x == y))
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "Prims.unit", "PulseCore.Atomic.pure_trivial", "Prims.eq2", "FStar.Ghost.reveal", "PulseCore.Atomic.stt_ghost", "PulseCore.InstantiatedSemantics.pure", "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.Action.return", "PulseCore.InstantiatedSemantics.emp" ]
[]
false
false
false
false
false
let ghost_reveal (a: Type) (x: erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) =
let m:stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload'
val gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t))
val gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t))
let gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (tg, consumed) -> let k = maybe_enum_key_of_repr (dsum_enum t) tg in synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) g (clens_dsum_unknown_payload t) input res } ))
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 105, "end_line": 1975, "start_col": 0, "start_line": 1955 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos #push-options "--z3rlimit 32" let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload #pop-options let valid_dsum_elim_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Unknown? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid g h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload inline_for_extraction let jump_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = jumper (parse_dsum_cases' s f g x) let jump_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : jump_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let jump_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (jump_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (jump_dsum_cases_t s f g x))) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: jump_dsum_cases_t s f g x) input len else (iff () <: jump_dsum_cases_t s f g x) input len inline_for_extraction let jump_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (jump_dsum_cases_eq s f g x)) = jump_dsum_cases_if' s f g x inline_for_extraction let jump_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = synth_dsum_case_injective s x; match x with | Known x' -> jump_synth (f' x') (synth_dsum_case s (Known x')) () <: jumper (parse_dsum_cases' s f g x) | Unknown x' -> jump_synth g' (synth_dsum_case s (Unknown x')) () <: jumper (parse_dsum_cases' s f g x) inline_for_extraction let jump_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> jump_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> jump_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> jump_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let jump_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jumper (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input pos; valid_facts (parse_dsum_cases s f g x) h input pos; parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input pos) in jump_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 16" inline_for_extraction let jump_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (jumper (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: jumper g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (jump_dsum_cases_t t f g)) : Tot (jumper (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input pos) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input pos in [@inline_let] let _ = valid_facts p h input pos in let pos_after_tag = v input pos in let tg = p32 input pos in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input pos_after_tag in destr (jump_dsum_cases_eq t f g) (jump_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options inline_for_extraction let read_dsum_cases' (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #rrel #rel input pos -> [@inline_let] let _ = synth_dsum_case_injective t x in match x with | Known x' -> read_synth' (dsnd (f x')) (synth_dsum_case t (Known x')) (f32 x') () input pos | Unknown x' -> read_synth' g (synth_dsum_case t (Unknown x')) g32 () input pos inline_for_extraction let read_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot Type = leaf_reader (parse_dsum_cases' t f g (Known k)) let read_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) (x y : read_dsum_cases_t t f g k) : GTot Type0 = True inline_for_extraction let read_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (if_combinator _ (read_dsum_cases_t_eq t f g k)) = fun cond (sv_true: cond_true cond -> Tot (read_dsum_cases_t t f g k)) (sv_false: cond_false cond -> Tot (read_dsum_cases_t t f g k)) #_ #_ input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let read_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #_ #_ input pos -> match x with | Known k -> destr _ (read_dsum_cases_t_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> read_dsum_cases' t f f32 g g32 (Known k)) k input pos | Unknown r -> read_dsum_cases' t f f32 g g32 (Unknown r) input pos #push-options "--z3rlimit 16" inline_for_extraction let read_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader (parse_maybe_enum_key p (dsum_enum t))) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) : Tot (leaf_reader (parse_dsum t p f g)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_maybe_enum_key j (dsum_enum t) input pos in valid_facts (parse_dsum_cases' t f g k) h input pos' ; read_dsum_cases t f f32 g g32 destr k input pos' #pop-options inline_for_extraction let serialize32_dsum_type_of_tag (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_type_of_tag t f sf g sg tg)) = match tg with | Known x' -> serialize32_ext (dsnd (f x')) (sf x') (sf32 x') (parse_dsum_type_of_tag t f g tg) () | Unknown x' -> serialize32_ext g sg sg32 (parse_dsum_type_of_tag t f g tg) () inline_for_extraction let serialize32_dsum_cases_aux (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = [@inline_let] let _ = synth_dsum_case_injective t tg in [@inline_let] let _ = synth_dsum_case_inverse t tg in serialize32_synth (serialize32_dsum_type_of_tag t f sf sf32 sg32 tg) (synth_dsum_case t tg) (synth_dsum_case_recip t tg) (fun x -> synth_dsum_case_recip t tg x) () inline_for_extraction let serialize32_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot Type = serializer32 (serialize_dsum_cases t f sf g sg (Known k)) let serialize32_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) (x y: serialize32_dsum_cases_t t f sf g sg k) : GTot Type0 = True inline_for_extraction let serialize32_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot (if_combinator _ (serialize32_dsum_cases_t_eq t f sf g sg k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) (sv_false: (cond_false cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) x #rrel #rel output pos -> if cond then (sv_true () x output pos) else (sv_false () x output pos) inline_for_extraction let serialize32_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = fun x #rrel #rel output pos -> match tg with | Known k -> destr _ (serialize32_dsum_cases_t_if t f sf g sg) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Known k)) k x output pos | Unknown r -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Unknown r) x output pos inline_for_extraction let serialize32_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_maybe_enum_key _ s (dsum_enum t))) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) : Tot (serializer32 (serialize_dsum t s f sf g sg)) = fun x #_ #_ output pos -> [@inline_let] let _ = serialize_dsum_eq' t s f sf g sg x in let tg = dsum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_dsum_cases t f sf sf32 sg32 destr tg) tg x output pos let clens_dsum_tag (s: dsum) : Tot (clens (dsum_type s) (dsum_key s)) = { clens_cond = (fun _ -> True); clens_get = dsum_tag_of_data s; } let gaccessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) (parse_maybe_enum_key p (dsum_enum t)) (clens_dsum_tag t)) = gaccessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) inline_for_extraction let accessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_dsum_tag t p f g)) = accessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) let clens_dsum_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_type s) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_type s) -> dsum_tag_of_data s x == k); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (dsum_tag_of_data s x == k)) (ensures (fun _ -> True))); } let clens_dsum_unknown_payload (s: dsum) : Tot (clens (dsum_type s) (dsum_type_of_unknown_tag s)) = { clens_cond = (fun (x: dsum_type s) -> Unknown? (dsum_tag_of_data s x)); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s (dsum_tag_of_data s x) x <: Ghost (dsum_type_of_unknown_tag s) (requires (Unknown? (dsum_tag_of_data s x))) (ensures (fun _ -> True))); } #push-options "--z3rlimit 16" let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res } )) let gaccessor_clens_dsum_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_injective t p f g k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_no_lookahead t p f g k x)); gaccessor_prop_equiv (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) (gaccessor_clens_dsum_payload' t p f g k); gaccessor_clens_dsum_payload' t p f g k inline_for_extraction let accessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_payload t k).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_payload t p f g k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_payload t p f g k) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (accessor (gaccessor_clens_dsum_payload t p f g k)) = fun #rrel #rel -> accessor_clens_dsum_payload' t j f g k #rrel #rel #push-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.dsum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.dsum_repr_type t) -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.Sum.parse_dsum t p f g) g (LowParse.Low.Sum.clens_dsum_unknown_payload t)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Sum.dsum", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Bytes.bytes", "Prims.nat", "LowParse.Low.Base.Spec.gaccessor_post'", "LowParse.Spec.Sum.parse_dsum_kind", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.parse_dsum", "LowParse.Low.Sum.clens_dsum_unknown_payload", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.consumed_length", "Prims.unit", "LowParse.Spec.Combinators.synth_injective_synth_inverse_synth_inverse_recip", "LowParse.Spec.Base.refine_with_tag", "LowParse.Spec.Sum.dsum_key", "LowParse.Spec.Sum.dsum_tag_of_data", "LowParse.Spec.Sum.dsum_type_of_tag", "LowParse.Spec.Sum.synth_dsum_case", "LowParse.Spec.Sum.synth_dsum_case_recip", "LowParse.Spec.Sum.synth_dsum_case_injective", "LowParse.Spec.Sum.synth_dsum_case_inverse", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Sum.dsum_key_type", "LowParse.Spec.Sum.dsum_enum", "LowParse.Spec.Enum.maybe_enum_key_of_repr", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Sum.parse_dsum_eq3", "LowParse.Low.Base.Spec.gaccessor'" ]
[]
false
false
false
false
false
let gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) =
fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (tg, consumed) -> let k = maybe_enum_key_of_repr (dsum_enum t) tg in synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) in (res <: (res: _{gaccessor_post' (parse_dsum t p f g) g (clens_dsum_unknown_payload t) input res}))
false
PulseCore.Atomic.fst
PulseCore.Atomic.drop
val drop (p:slprop) : stt_ghost unit p (fun _ -> emp)
val drop (p:slprop) : stt_ghost unit p (fun _ -> emp)
let drop p = Ghost.hide (A.drop p)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 305, "start_col": 0, "start_line": 305 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f let ghost_write r x y f = Ghost.hide (A.write r x y f) let ghost_share r v0 v1 = Ghost.hide (A.share r v0 v1) let ghost_gather r v0 v1 = Ghost.hide (A.gather r v0 v1) let ghost_witnessed (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (f:property a) = witnessed (reveal r) f let ghost_witness (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) = Ghost.hide (A.witness r fact v pf) let ghost_recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a) (r:ghost_ref pcm) (v:Ghost.erased a) (w:ghost_witnessed r fact) = Ghost.hide (A.recall r v w)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: PulseCore.InstantiatedSemantics.slprop -> PulseCore.Atomic.stt_ghost Prims.unit p (fun _ -> PulseCore.InstantiatedSemantics.emp)
Prims.Tot
[ "total" ]
[]
[ "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.emp", "PulseCore.Action.drop", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let drop p =
Ghost.hide (A.drop p)
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_witness
val ghost_witness (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) : stt_ghost (ghost_witnessed r fact) (ghost_pts_to r v) (fun _ -> ghost_pts_to r v)
val ghost_witness (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) : stt_ghost (ghost_witnessed r fact) (ghost_pts_to r v) (fun _ -> ghost_pts_to r v)
let ghost_witness (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) = Ghost.hide (A.witness r fact v pf)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 294, "start_col": 0, "start_line": 287 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f let ghost_write r x y f = Ghost.hide (A.write r x y f) let ghost_share r v0 v1 = Ghost.hide (A.share r v0 v1) let ghost_gather r v0 v1 = Ghost.hide (A.gather r v0 v1) let ghost_witnessed (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (f:property a) = witnessed (reveal r) f
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref pcm -> fact: PulseCore.Action.stable_property pcm -> v: FStar.Ghost.erased a -> pf: Prims.squash (forall (z: a). FStar.PCM.compatible pcm (FStar.Ghost.reveal v) z ==> fact z) -> PulseCore.Atomic.stt_ghost (PulseCore.Atomic.ghost_witnessed r fact) (PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v)) (fun _ -> PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "PulseCore.Action.stable_property", "FStar.Ghost.erased", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "FStar.PCM.compatible", "FStar.Ghost.reveal", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Atomic.ghost_witnessed", "PulseCore.Action.emp_inames", "PulseCore.Atomic.ghost_pts_to", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.witness", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let ghost_witness (#a: Type) (#pcm: pcm a) (r: ghost_ref pcm) (fact: stable_property pcm) (v: Ghost.erased a) (pf: squash (forall z. compatible pcm v z ==> fact z)) =
Ghost.hide (A.witness r fact v pf)
false
PulseCore.Atomic.fst
PulseCore.Atomic.read
val read (#a:Type) (#p:pcm a) (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}))) : stt_atomic (v:a{compatible p x v /\ p.refine v}) #Observable emp_inames (pts_to r x) (fun v -> pts_to r (f v))
val read (#a:Type) (#p:pcm a) (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}))) : stt_atomic (v:a{compatible p x v /\ p.refine v}) #Observable emp_inames (pts_to r x) (fun v -> pts_to r (f v))
let read = A.read
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 242, "start_col": 0, "start_line": 242 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Action.ref a p -> x: FStar.Ghost.erased a -> f: (v: a{FStar.PCM.compatible p (FStar.Ghost.reveal x) v} -> Prims.GTot (y: a{FStar.PCM.compatible p y v /\ FStar.PCM.frame_compatible p x v y})) -> PulseCore.Atomic.stt_atomic (v: a{FStar.PCM.compatible p (FStar.Ghost.reveal x) v /\ Mkpcm?.refine p v}) PulseCore.Action.emp_inames (PulseCore.Action.pts_to r (FStar.Ghost.reveal x)) (fun v -> PulseCore.Action.pts_to r (f v))
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Action.read" ]
[]
false
false
false
false
false
let read =
A.read
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_recall
val ghost_recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a) (r:ghost_ref pcm) (v:Ghost.erased a) (w:ghost_witnessed r fact) : stt_ghost (v1:Ghost.erased a{compatible pcm v v1}) (ghost_pts_to r v) (fun v1 -> ghost_pts_to r v ** pure (fact v1))
val ghost_recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a) (r:ghost_ref pcm) (v:Ghost.erased a) (w:ghost_witnessed r fact) : stt_ghost (v1:Ghost.erased a{compatible pcm v v1}) (ghost_pts_to r v) (fun v1 -> ghost_pts_to r v ** pure (fact v1))
let ghost_recall (#a:Type u#1) (#pcm:pcm a) (#fact:property a) (r:ghost_ref pcm) (v:Ghost.erased a) (w:ghost_witnessed r fact) = Ghost.hide (A.recall r v w)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 29, "end_line": 303, "start_col": 0, "start_line": 296 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f let ghost_write r x y f = Ghost.hide (A.write r x y f) let ghost_share r v0 v1 = Ghost.hide (A.share r v0 v1) let ghost_gather r v0 v1 = Ghost.hide (A.gather r v0 v1) let ghost_witnessed (#a:Type u#1) (#p:pcm a) (r:ghost_ref p) (f:property a) = witnessed (reveal r) f let ghost_witness (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (fact:stable_property pcm) (v:Ghost.erased a) (pf:squash (forall z. compatible pcm v z ==> fact z)) = Ghost.hide (A.witness r fact v pf)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref pcm -> v: FStar.Ghost.erased a -> w: PulseCore.Atomic.ghost_witnessed r fact -> PulseCore.Atomic.stt_ghost (v1: FStar.Ghost.erased a {FStar.PCM.compatible pcm (FStar.Ghost.reveal v) (FStar.Ghost.reveal v1)}) (PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v)) (fun v1 -> PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v) ** PulseCore.InstantiatedSemantics.pure (fact (FStar.Ghost.reveal v1)))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Action.property", "PulseCore.Atomic.ghost_ref", "FStar.Ghost.erased", "PulseCore.Atomic.ghost_witnessed", "FStar.Ghost.hide", "PulseCore.Action.act", "FStar.PCM.compatible", "FStar.Ghost.reveal", "PulseCore.Action.emp_inames", "PulseCore.Atomic.ghost_pts_to", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.pure", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.recall", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let ghost_recall (#a: Type u#1) (#pcm: pcm a) (#fact: property a) (r: ghost_ref pcm) (v: Ghost.erased a) (w: ghost_witnessed r fact) =
Ghost.hide (A.recall r v w)
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload_no_lookahead
val gaccessor_clens_dsum_unknown_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl': bytes) : Lemma (requires ((parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl')) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl'))
val gaccessor_clens_dsum_unknown_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl': bytes) : Lemma (requires ((parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl')) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl'))
let gaccessor_clens_dsum_unknown_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl'
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 2017, "start_col": 0, "start_line": 1997 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos #push-options "--z3rlimit 32" let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload #pop-options let valid_dsum_elim_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Unknown? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid g h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload inline_for_extraction let jump_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = jumper (parse_dsum_cases' s f g x) let jump_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : jump_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let jump_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (jump_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (jump_dsum_cases_t s f g x))) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: jump_dsum_cases_t s f g x) input len else (iff () <: jump_dsum_cases_t s f g x) input len inline_for_extraction let jump_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (jump_dsum_cases_eq s f g x)) = jump_dsum_cases_if' s f g x inline_for_extraction let jump_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = synth_dsum_case_injective s x; match x with | Known x' -> jump_synth (f' x') (synth_dsum_case s (Known x')) () <: jumper (parse_dsum_cases' s f g x) | Unknown x' -> jump_synth g' (synth_dsum_case s (Unknown x')) () <: jumper (parse_dsum_cases' s f g x) inline_for_extraction let jump_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> jump_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> jump_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> jump_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let jump_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jumper (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input pos; valid_facts (parse_dsum_cases s f g x) h input pos; parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input pos) in jump_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 16" inline_for_extraction let jump_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (jumper (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: jumper g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (jump_dsum_cases_t t f g)) : Tot (jumper (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input pos) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input pos in [@inline_let] let _ = valid_facts p h input pos in let pos_after_tag = v input pos in let tg = p32 input pos in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input pos_after_tag in destr (jump_dsum_cases_eq t f g) (jump_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options inline_for_extraction let read_dsum_cases' (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #rrel #rel input pos -> [@inline_let] let _ = synth_dsum_case_injective t x in match x with | Known x' -> read_synth' (dsnd (f x')) (synth_dsum_case t (Known x')) (f32 x') () input pos | Unknown x' -> read_synth' g (synth_dsum_case t (Unknown x')) g32 () input pos inline_for_extraction let read_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot Type = leaf_reader (parse_dsum_cases' t f g (Known k)) let read_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) (x y : read_dsum_cases_t t f g k) : GTot Type0 = True inline_for_extraction let read_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (if_combinator _ (read_dsum_cases_t_eq t f g k)) = fun cond (sv_true: cond_true cond -> Tot (read_dsum_cases_t t f g k)) (sv_false: cond_false cond -> Tot (read_dsum_cases_t t f g k)) #_ #_ input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let read_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #_ #_ input pos -> match x with | Known k -> destr _ (read_dsum_cases_t_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> read_dsum_cases' t f f32 g g32 (Known k)) k input pos | Unknown r -> read_dsum_cases' t f f32 g g32 (Unknown r) input pos #push-options "--z3rlimit 16" inline_for_extraction let read_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader (parse_maybe_enum_key p (dsum_enum t))) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) : Tot (leaf_reader (parse_dsum t p f g)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_maybe_enum_key j (dsum_enum t) input pos in valid_facts (parse_dsum_cases' t f g k) h input pos' ; read_dsum_cases t f f32 g g32 destr k input pos' #pop-options inline_for_extraction let serialize32_dsum_type_of_tag (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_type_of_tag t f sf g sg tg)) = match tg with | Known x' -> serialize32_ext (dsnd (f x')) (sf x') (sf32 x') (parse_dsum_type_of_tag t f g tg) () | Unknown x' -> serialize32_ext g sg sg32 (parse_dsum_type_of_tag t f g tg) () inline_for_extraction let serialize32_dsum_cases_aux (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = [@inline_let] let _ = synth_dsum_case_injective t tg in [@inline_let] let _ = synth_dsum_case_inverse t tg in serialize32_synth (serialize32_dsum_type_of_tag t f sf sf32 sg32 tg) (synth_dsum_case t tg) (synth_dsum_case_recip t tg) (fun x -> synth_dsum_case_recip t tg x) () inline_for_extraction let serialize32_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot Type = serializer32 (serialize_dsum_cases t f sf g sg (Known k)) let serialize32_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) (x y: serialize32_dsum_cases_t t f sf g sg k) : GTot Type0 = True inline_for_extraction let serialize32_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot (if_combinator _ (serialize32_dsum_cases_t_eq t f sf g sg k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) (sv_false: (cond_false cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) x #rrel #rel output pos -> if cond then (sv_true () x output pos) else (sv_false () x output pos) inline_for_extraction let serialize32_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = fun x #rrel #rel output pos -> match tg with | Known k -> destr _ (serialize32_dsum_cases_t_if t f sf g sg) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Known k)) k x output pos | Unknown r -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Unknown r) x output pos inline_for_extraction let serialize32_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_maybe_enum_key _ s (dsum_enum t))) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) : Tot (serializer32 (serialize_dsum t s f sf g sg)) = fun x #_ #_ output pos -> [@inline_let] let _ = serialize_dsum_eq' t s f sf g sg x in let tg = dsum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_dsum_cases t f sf sf32 sg32 destr tg) tg x output pos let clens_dsum_tag (s: dsum) : Tot (clens (dsum_type s) (dsum_key s)) = { clens_cond = (fun _ -> True); clens_get = dsum_tag_of_data s; } let gaccessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) (parse_maybe_enum_key p (dsum_enum t)) (clens_dsum_tag t)) = gaccessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) inline_for_extraction let accessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_dsum_tag t p f g)) = accessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) let clens_dsum_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_type s) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_type s) -> dsum_tag_of_data s x == k); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (dsum_tag_of_data s x == k)) (ensures (fun _ -> True))); } let clens_dsum_unknown_payload (s: dsum) : Tot (clens (dsum_type s) (dsum_type_of_unknown_tag s)) = { clens_cond = (fun (x: dsum_type s) -> Unknown? (dsum_tag_of_data s x)); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s (dsum_tag_of_data s x) x <: Ghost (dsum_type_of_unknown_tag s) (requires (Unknown? (dsum_tag_of_data s x))) (ensures (fun _ -> True))); } #push-options "--z3rlimit 16" let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res } )) let gaccessor_clens_dsum_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl /\ gaccessor_pre (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl' )) (ensures ( gaccessor_clens_dsum_payload' t p f g k sl == gaccessor_clens_dsum_payload' t p f g k sl' )) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl' ; parse_injective p sl sl' let gaccessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_injective t p f g k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_dsum_payload_no_lookahead t p f g k x)); gaccessor_prop_equiv (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) (gaccessor_clens_dsum_payload' t p f g k); gaccessor_clens_dsum_payload' t p f g k inline_for_extraction let accessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_dsum t p f g) h input pos /\ (clens_dsum_payload t k).clens_cond (contents (parse_dsum t p f g) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_dsum_payload t p f g k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_dsum t p f g) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_dsum_payload t p f g k) input pos; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq3 t p f g large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_dsum_payload (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (accessor (gaccessor_clens_dsum_payload t p f g k)) = fun #rrel #rel -> accessor_clens_dsum_payload' t j f g k #rrel #rel #push-options "--z3rlimit 16" let gaccessor_clens_dsum_unknown_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor' (parse_dsum t p f g) g (clens_dsum_unknown_payload t)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (tg, consumed) -> let k = maybe_enum_key_of_repr (dsum_enum t) tg in synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) g (clens_dsum_unknown_payload t) input res } )) let gaccessor_clens_dsum_unknown_payload_injective (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ injective_precond (parse_dsum t p f g) sl sl' )) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) = parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_injective (parse_dsum t p f g) sl sl' ; parse_injective p sl sl'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.dsum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.dsum_repr_type t) -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> sl: LowParse.Bytes.bytes -> sl': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires Mkparser_kind'?.parser_kind_subkind (LowParse.Spec.Sum.parse_dsum_kind kt t f ku) == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.Sum.parse_dsum t p f g) g (LowParse.Low.Sum.clens_dsum_unknown_payload t) sl /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.Sum.parse_dsum t p f g) g (LowParse.Low.Sum.clens_dsum_unknown_payload t) sl' /\ LowParse.Spec.Base.no_lookahead_on_precond (LowParse.Spec.Sum.parse_dsum t p f g) sl sl') (ensures LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload' t p f g sl == LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload' t p f g sl')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Sum.dsum", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse_injective", "Prims.unit", "LowParse.Spec.Base.parse_strong_prefix", "LowParse.Spec.Sum.parse_dsum_kind", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.parse_dsum", "LowParse.Spec.Sum.parse_dsum_eq3", "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", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Low.Sum.clens_dsum_unknown_payload", "LowParse.Spec.Base.no_lookahead_on_precond", "Prims.squash", "Prims.nat", "LowParse.Low.Sum.gaccessor_clens_dsum_unknown_payload'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gaccessor_clens_dsum_unknown_payload_no_lookahead (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (sl sl': bytes) : Lemma (requires ((parse_dsum_kind kt t f ku).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl /\ gaccessor_pre (parse_dsum t p f g) g (clens_dsum_unknown_payload t) sl' /\ no_lookahead_on_precond (parse_dsum t p f g) sl sl')) (ensures (gaccessor_clens_dsum_unknown_payload' t p f g sl == gaccessor_clens_dsum_unknown_payload' t p f g sl')) =
parse_dsum_eq3 t p f g sl; parse_dsum_eq3 t p f g sl'; parse_strong_prefix (parse_dsum t p f g) sl sl'; parse_injective p sl sl'
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_alloc
val ghost_alloc (#a:Type u#1) (#pcm:pcm a) (x:erased a{compatible pcm x x /\ pcm.refine x}) : stt_ghost (ghost_ref pcm) emp (fun r -> ghost_pts_to r x)
val ghost_alloc (#a:Type u#1) (#pcm:pcm a) (x:erased a{compatible pcm x x /\ pcm.refine x}) : stt_ghost (ghost_ref pcm) emp (fun r -> ghost_pts_to r x)
let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 261, "start_col": 0, "start_line": 261 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r))
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Ghost.erased a { FStar.PCM.compatible pcm (FStar.Ghost.reveal x) (FStar.Ghost.reveal x) /\ Mkpcm?.refine pcm (FStar.Ghost.reveal x) } -> PulseCore.Atomic.stt_ghost (PulseCore.Atomic.ghost_ref pcm) PulseCore.InstantiatedSemantics.emp (fun r -> PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal x))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "FStar.Ghost.erased", "Prims.l_and", "FStar.PCM.compatible", "FStar.Ghost.reveal", "FStar.PCM.__proj__Mkpcm__item__refine", "PulseCore.Atomic.hide_ghost", "PulseCore.Action.ref", "PulseCore.InstantiatedSemantics.emp", "PulseCore.Action.pts_to", "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.Action.alloc", "PulseCore.Atomic.stt_ghost", "PulseCore.Atomic.ghost_ref", "PulseCore.Atomic.ghost_pts_to" ]
[]
false
false
false
false
false
let ghost_alloc #a #pcm x =
hide_ghost (Ghost.hide <| A.alloc #a x)
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_read
val ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v))
val ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v))
let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 273, "start_col": 0, "start_line": 262 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r))
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref p -> x: FStar.Ghost.erased a -> f: (v: a{FStar.PCM.compatible p (FStar.Ghost.reveal x) v} -> Prims.GTot (y: a{FStar.PCM.compatible p y v /\ FStar.PCM.frame_compatible p x v y})) -> PulseCore.Atomic.stt_ghost (FStar.Ghost.erased (v: a{FStar.PCM.compatible p (FStar.Ghost.reveal x) v /\ Mkpcm?.refine p v})) (PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal x)) (fun v -> PulseCore.Atomic.ghost_pts_to r (f (FStar.Ghost.reveal v)))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "FStar.Ghost.erased", "FStar.PCM.compatible", "FStar.Ghost.reveal", "Prims.l_and", "FStar.PCM.frame_compatible", "PulseCore.Atomic.hide_ghost", "FStar.PCM.__proj__Mkpcm__item__refine", "PulseCore.Atomic.ghost_pts_to", "PulseCore.Action.pts_to", "PulseCore.Action.ref", "PulseCore.InstantiatedSemantics.slprop", "FStar.Ghost.hide", "PulseCore.Action.act", "PulseCore.Action.emp_inames", "PulseCore.Action.read", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let ghost_read (#a: Type) (#p: pcm a) (r: ghost_ref 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}))) : stt_ghost (erased (v: a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) =
hide_ghost <| (Ghost.hide <| A.read r x f)
false
PulseCore.Atomic.fst
PulseCore.Atomic.share
val share (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a{composable pcm v0 v1}) : stt_ghost unit (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 ** pts_to r v1)
val share (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a{composable pcm v0 v1}) : stt_ghost unit (pts_to r (v0 `op pcm` v1)) (fun _ -> pts_to r v0 ** pts_to r v1)
let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 244, "start_col": 0, "start_line": 244 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Action.ref a pcm -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a {FStar.PCM.composable pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1)} -> PulseCore.Atomic.stt_ghost Prims.unit (PulseCore.Action.pts_to r (FStar.PCM.op pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1))) (fun _ -> PulseCore.Action.pts_to r (FStar.Ghost.reveal v0) ** PulseCore.Action.pts_to r (FStar.Ghost.reveal v1))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Action.ref", "FStar.Ghost.erased", "FStar.PCM.composable", "FStar.Ghost.reveal", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "PulseCore.Action.pts_to", "FStar.PCM.op", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.share", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let share #a #pcm r v0 v1 =
Ghost.hide (A.share r v0 v1)
false
Steel.HigherReference.fst
Steel.HigherReference.free
val free (#a:Type) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp)
val free (#a:Type) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp)
let free (#a:Type) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) = let v_old : erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, full_perm)) in rewrite_slprop (pts_to r full_perm v) (RP.pts_to r v_old `star` pure (perm_ok full_perm)) (fun _ -> ()); elim_pure (perm_ok full_perm); RP.free r v_old; drop (RP.pts_to r (Mkpcm'?.one (Mkpcm?.p pcm_frac)))
{ "file_name": "lib/steel/Steel.HigherReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 221, "start_col": 0, "start_line": 212 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.HigherReference open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open FStar.PCM open Steel.PCMFrac open FStar.Real module RP = Steel.PCMReference #set-options "--ide_id_info_off" module Mem = Steel.Memory let ref a = Mem.ref (fractional a) pcm_frac let null #a = Mem.null #(fractional a) #pcm_frac let is_null #a r = Mem.is_null #(fractional a) #pcm_frac r let perm_ok p : prop = (p.v <=. one == true) /\ True let pts_to_raw_sl (#a:Type) (r:ref a) (p:perm) (v:erased a) : slprop = Mem.pts_to r (Some (Ghost.reveal v, p)) let pts_to_raw (#a:Type) (r:ref a) (p:perm) (v:erased a) : vprop = to_vprop (Mem.pts_to r (Some (Ghost.reveal v, p))) [@@__reduce__] let pts_to' (#a:Type u#1) (r:ref a) (p:perm) (v:erased a) : vprop = pts_to_raw r p v `star` pure (perm_ok p) let pts_to_sl #a r p v = hp_of (pts_to' r p v) let abcd_acbd (a b c d:slprop) : Lemma (Mem.(((a `star` b) `star` (c `star` d)) `equiv` ((a `star` c) `star` (b `star` d)))) = let open Steel.Memory in calc (equiv) { ((a `star` b) `star` (c `star` d)); (equiv) { star_associative a b (c `star` d) } ((a `star` (b `star` (c `star` d)))); (equiv) { star_associative b c d; star_congruence a (b `star` (c `star` d)) a ((b `star` c) `star` d) } (a `star` ((b `star` c) `star` d)); (equiv) { star_commutative b c; star_congruence (b `star` c) d (c `star` b) d; star_congruence a ((b `star` c) `star` d) a ((c `star` b) `star` d) } (a `star` ((c `star` b) `star` d)); (equiv) { star_associative c b d; star_congruence a ((c `star` b) `star` d) a (c `star` (b `star` d)) } (a `star` (c `star` (b `star` d))); (equiv) { star_associative a c (b `star` d) } ((a `star` c) `star` (b `star` d)); } let pts_to_ref_injective (#a: Type u#1) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) = let open Steel.Memory in abcd_acbd (hp_of (pts_to_raw r p0 v0)) (pure (perm_ok p0)) (hp_of (pts_to_raw r p1 v1)) (pure (perm_ok p1)); Mem.affine_star (hp_of (pts_to_raw r p0 v0) `star` hp_of (pts_to_raw r p1 v1)) (pure (perm_ok p0) `star` pure (perm_ok p1)) m; Mem.pts_to_compatible r (Some (Ghost.reveal v0, p0)) (Some (Ghost.reveal v1, p1)) m let pts_to_not_null (#a:Type u#1) (r:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures r =!= null) = Mem.affine_star (hp_of (pts_to_raw r p v)) (Mem.pure (perm_ok p)) m; Mem.pts_to_not_null r (Some (Ghost.reveal v, p)) m let pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) = let aux (x y : erased a) (m:mem) : Lemma (requires (interp (pts_to_sl r p x) m /\ interp (pts_to_sl r p y) m)) (ensures (x == y)) = Mem.pts_to_join r (Some (Ghost.reveal x, p)) (Some (Ghost.reveal y, p)) m in Classical.forall_intro_3 (fun x y -> Classical.move_requires (aux x y)) let higher_ref_pts_to_injective_eq #a #opened #p0 #p1 #v0 #v1 r = extract_info_raw (pts_to r p0 v0 `star` pts_to r p1 v1) (v0 == v1) (fun m -> pts_to_ref_injective r p0 p1 v0 v1 m); rewrite_slprop (pts_to r p1 v1) (pts_to r p1 v0) (fun _ -> ()) let pts_to_framon (#a:Type) (r:ref a) (p:perm) : Lemma (is_frame_monotonic (pts_to_sl r p)) = pts_to_witinv r p let intro_pts_to (p:perm) #a #uses (#v:erased a) (r:ref a) : SteelGhost unit uses (pts_to_raw r p v) (fun _ -> pts_to r p v) (requires fun _ -> perm_ok p) (ensures fun _ _ _ -> True) = intro_pure (perm_ok p); rewrite_slprop (pts_to' r p v) (pts_to r p v) (fun _ -> ()) let pts_to_perm #_ #_ #p #v r = rewrite_slprop (pts_to r p v) (pts_to' r p v) (fun _ -> ()); elim_pure (perm_ok p); intro_pure (perm_ok p); rewrite_slprop (pts_to' r p v) (pts_to r p v) (fun _ -> ()) let alloc #a x = let v = Some (x, full_perm) in assert (FStar.PCM.composable pcm_frac v None); assert (compatible pcm_frac v v); let r = RP.alloc v in rewrite_slprop (RP.pts_to r v) (pts_to r full_perm x) (fun m -> emp_unit (hp_of (pts_to_raw r full_perm x)); pure_star_interp (hp_of (pts_to_raw r full_perm x)) (perm_ok full_perm) m ); extract_info_raw (pts_to r full_perm x) (~ (is_null r)) (fun m -> pts_to_not_null r full_perm x m); return r let read (#a:Type) (#p:perm) (#v:erased a) (r:ref a) = let v1 : erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, p)) in rewrite_slprop (pts_to r p v) (RP.pts_to r v1 `star` pure (perm_ok p)) (fun _ -> ()); elim_pure (perm_ok p); let v2 = RP.read r v1 in rewrite_slprop (RP.pts_to r v1) (pts_to r p v) (fun m -> emp_unit (hp_of (pts_to_raw r p v)); pure_star_interp (hp_of (pts_to_raw r p v)) (perm_ok p) m); assert (compatible pcm_frac v1 v2); let Some (x, _) = v2 in rewrite_slprop (pts_to r p v) (pts_to r p x) (fun _ -> ()); return x let atomic_read (#opened:_) (#a:Type) (#p:perm) (#v:erased a) (r:ref a) = let v1 : erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, p)) in rewrite_slprop (pts_to r p v) (RP.pts_to r v1 `star` pure (perm_ok p)) (fun _ -> ()); elim_pure (perm_ok p); let v2 = RP.atomic_read r v1 in rewrite_slprop (RP.pts_to r v1) (pts_to r p v) (fun m -> emp_unit (hp_of (pts_to_raw r p v)); pure_star_interp (hp_of (pts_to_raw r p v)) (perm_ok p) m); assert (compatible pcm_frac v1 v2); let Some (x, _) = v2 in rewrite_slprop (pts_to r p v) (pts_to r p x) (fun _ -> ()); return x let read_refine (#a:Type) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) = let vs:erased a = witness_exists () in rewrite_slprop (pts_to r p (Ghost.hide (Ghost.reveal vs))) (pts_to r p vs) (fun _ -> ()); let v = read r in rewrite_slprop (q vs) (q v) (fun _ -> ()); return v let write (#a:Type) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) = let v_old : erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, full_perm)) in let v_new : fractional a = Some (x, full_perm) in rewrite_slprop (pts_to r full_perm v) (RP.pts_to r v_old `star` pure (perm_ok full_perm)) (fun _ -> ()); elim_pure (perm_ok full_perm); RP.write r v_old v_new; rewrite_slprop (RP.pts_to r v_new) (pts_to r full_perm x) (fun m -> emp_unit (hp_of (pts_to_raw r full_perm x)); pure_star_interp (hp_of (pts_to_raw r full_perm x)) (perm_ok full_perm) m) let atomic_write #opened #a #v r x = let v_old : erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, full_perm)) in let v_new : fractional a = Some (x, full_perm) in rewrite_slprop (pts_to r full_perm v) (RP.pts_to r v_old `star` pure (perm_ok full_perm)) (fun _ -> ()); elim_pure (perm_ok full_perm); RP.atomic_write r v_old v_new; rewrite_slprop (RP.pts_to r v_new) (pts_to r full_perm x) (fun m -> emp_unit (hp_of (pts_to_raw r full_perm x)); pure_star_interp (hp_of (pts_to_raw r full_perm x)) (perm_ok full_perm) m)
{ "checked_file": "/", "dependencies": [ "Steel.PCMReference.fsti.checked", "Steel.PCMFrac.fst.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Real.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.NMSTTotal.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Steel.HigherReference.fst" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "RP" }, { "abbrev": false, "full_module": "FStar.Real", "short_module": null }, { "abbrev": false, "full_module": "Steel.PCMFrac", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.HigherReference.ref a -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "FStar.Ghost.erased", "Steel.HigherReference.ref", "Steel.Effect.Atomic.drop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.PCMReference.pts_to", "Steel.PCMFrac.fractional", "Steel.PCMFrac.pcm_frac", "FStar.PCM.__proj__Mkpcm'__item__one", "FStar.PCM.__proj__Mkpcm__item__p", "Prims.unit", "Steel.PCMReference.free", "Steel.Effect.Atomic.elim_pure", "Steel.HigherReference.perm_ok", "Steel.FractionalPermission.full_perm", "Steel.Effect.Atomic.rewrite_slprop", "Steel.HigherReference.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.star", "Steel.Effect.Common.pure", "Steel.Memory.mem", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "Steel.FractionalPermission.perm", "FStar.Pervasives.Native.Mktuple2", "Steel.Effect.Common.emp", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let free (#a: Type) (#v: erased a) (r: ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) =
let v_old:erased (fractional a) = Ghost.hide (Some (Ghost.reveal v, full_perm)) in rewrite_slprop (pts_to r full_perm v) ((RP.pts_to r v_old) `star` (pure (perm_ok full_perm))) (fun _ -> ()); elim_pure (perm_ok full_perm); RP.free r v_old; drop (RP.pts_to r (Mkpcm'?.one (Mkpcm?.p pcm_frac)))
false
PulseCore.Atomic.fst
PulseCore.Atomic.gather
val gather (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a) : stt_ghost (squash (composable pcm v0 v1)) (pts_to r v0 ** pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
val gather (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a) : stt_ghost (squash (composable pcm v0 v1)) (pts_to r v0 ** pts_to r v1) (fun _ -> pts_to r (op pcm v0 v1))
let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 245, "start_col": 0, "start_line": 245 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Action.ref a pcm -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a -> PulseCore.Atomic.stt_ghost (Prims.squash (FStar.PCM.composable pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1))) (PulseCore.Action.pts_to r (FStar.Ghost.reveal v0) ** PulseCore.Action.pts_to r (FStar.Ghost.reveal v1)) (fun _ -> PulseCore.Action.pts_to r (FStar.PCM.op pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1)))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Action.ref", "FStar.Ghost.erased", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.squash", "FStar.PCM.composable", "FStar.Ghost.reveal", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.Action.pts_to", "FStar.PCM.op", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.gather", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let gather #a #pcm r v0 v1 =
Ghost.hide (A.gather r v0 v1)
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_share
val ghost_share (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a{composable pcm v0 v1}) : stt_ghost unit (ghost_pts_to r (v0 `op pcm` v1)) (fun _ -> ghost_pts_to r v0 ** ghost_pts_to r v1)
val ghost_share (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a{composable pcm v0 v1}) : stt_ghost unit (ghost_pts_to r (v0 `op pcm` v1)) (fun _ -> ghost_pts_to r v0 ** ghost_pts_to r v1)
let ghost_share r v0 v1 = Ghost.hide (A.share r v0 v1)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 277, "start_col": 0, "start_line": 277 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f let ghost_write r x y f = Ghost.hide (A.write r x y f)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref pcm -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a {FStar.PCM.composable pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1)} -> PulseCore.Atomic.stt_ghost Prims.unit (PulseCore.Atomic.ghost_pts_to r (FStar.PCM.op pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1))) (fun _ -> PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v0) ** PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v1))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "FStar.Ghost.erased", "FStar.PCM.composable", "FStar.Ghost.reveal", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.unit", "PulseCore.Action.emp_inames", "PulseCore.Atomic.ghost_pts_to", "FStar.PCM.op", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.share", "PulseCore.Action.ref", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let ghost_share r v0 v1 =
Ghost.hide (A.share r v0 v1)
false
WasmSupport.fst
WasmSupport.align_64
val align_64 (x: U32.t) : Tot U32.t
val align_64 (x: U32.t) : Tot U32.t
let align_64 (x: U32.t): Tot U32.t = if not ( U32.((x &^ 0x07ul) =^ 0ul) ) then U32.( (x &^ lognot 0x07ul) +%^ 0x08ul ) else x
{ "file_name": "runtime/WasmSupport.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 5, "end_line": 31, "start_col": 0, "start_line": 27 }
module WasmSupport open FStar.HyperStack.ST module C = FStar.Int.Cast module I64 = FStar.Int64 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module B = LowStar.Buffer open LowStar.BufferOps open FStar.Mul (* Functions implemented primitively in JS. No F* client should call those! *) assume val trap: Prims.string -> Stack unit (fun _ -> True) (fun _ _ _ -> False) (* Really not meant to be called by F* clients... *) assume val malloc: U32.t -> Stack U32.t (fun _ -> False) (fun _ _ _ -> False) (* Functions that the code-generator expects to find, either at the Ast, CFlat * or Wasm levels. In SimplifyWasm.ml, we prefix these with their module (before * "to_c_names". After that, e.g. in CFlatToWasm.ml, we can refer to them with * their short names, e.g. align_64. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "WasmSupport.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> FStar.UInt32.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.op_Negation", "FStar.UInt32.op_Equals_Hat", "FStar.UInt32.op_Amp_Hat", "FStar.UInt32.__uint_to_t", "FStar.UInt32.op_Plus_Percent_Hat", "FStar.UInt32.lognot", "Prims.bool" ]
[]
false
false
false
true
false
let align_64 (x: U32.t) : Tot U32.t =
if not (let open U32 in (x &^ 0x07ul) =^ 0ul) then let open U32 in (x &^ lognot 0x07ul) +%^ 0x08ul else x
false
PulseCore.Atomic.fst
PulseCore.Atomic.ghost_gather
val ghost_gather (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a) : stt_ghost (squash (composable pcm v0 v1)) (ghost_pts_to r v0 ** ghost_pts_to r v1) (fun _ -> ghost_pts_to r (op pcm v0 v1))
val ghost_gather (#a:Type) (#pcm:pcm a) (r:ghost_ref pcm) (v0:FStar.Ghost.erased a) (v1:FStar.Ghost.erased a) : stt_ghost (squash (composable pcm v0 v1)) (ghost_pts_to r v0 ** ghost_pts_to r v1) (fun _ -> ghost_pts_to r (op pcm v0 v1))
let ghost_gather r v0 v1 = Ghost.hide (A.gather r v0 v1)
{ "file_name": "lib/pulse_core/PulseCore.Atomic.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 278, "start_col": 0, "start_line": 278 }
module PulseCore.Atomic module I = PulseCore.InstantiatedSemantics module A = PulseCore.Action open PulseCore.InstantiatedSemantics open PulseCore.Action let stt_atomic a #obs opens pre post = A.act a opens pre post let pure_equiv (p q:prop) (_:squash (p <==> q)) : slprop_equiv (pure p) (pure q) = FStar.PropositionalExtensionality.apply p q; slprop_equiv_refl (pure p) let equiv (#p #q:slprop) (pf:slprop_equiv p q) : squash (p == q) = let _ : squash (slprop_equiv p q) = FStar.Squash.return_squash pf in I.slprop_equiv_elim p q let pure_trivial (p:prop) (_:squash p) : squash (pure p == emp) = calc (==) { pure p; (==) { equiv (pure_equiv p True ()) } pure True; (==) { equiv (A.pure_true ()) } emp; } let emp_unit_r (p:slprop) : squash (p ** emp == p) = calc (==) { (p ** emp); (==) { equiv (slprop_equiv_comm p emp) } (emp ** p); (==) { equiv (slprop_equiv_unit p) } p; } let return_atomic' #a x post : stt_atomic a #Unobservable emp_inames (post x ** pure (x == x)) (fun r -> post r ** pure (r == x)) = A.return #a #(fun r -> post r ** pure (r == x)) x let return_atomic #a x post : stt_atomic a #Neutral emp_inames (post x) (fun r -> post r ** pure (r == x)) = emp_unit_r (post x); pure_trivial (x == x) (); coerce_eq () (return_atomic' #a x post) let return_atomic_noeq #a x post = A.return #a #post x let bind_atomic (#a:Type u#a) (#b:Type u#b) (#obs1:_) (#obs2:observability { at_most_one_observable obs1 obs2 }) (#opens:inames) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_atomic a #obs1 opens pre1 post1) (e2:(x:a -> stt_atomic b #obs2 opens (post1 x) post2)) = A.bind e1 e2 let lift_observability (#a:Type u#a) (#obs #obs':_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) = e let lift_atomic0 (#a:Type u#0) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift0 e let lift_atomic1 (#a:Type u#1) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift1 e let lift_atomic2 (#a:Type u#2) (#obs:_) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens pre post) : stt a pre post = A.lift2 e let frame_atomic (#a:Type u#a) (#obs: observability) (#opens:inames) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_atomic a #obs opens pre post) : stt_atomic a #obs opens (pre ** frame) (fun x -> post x ** frame) = A.frame e let sub_atomic (#a:Type u#a) (#obs:_) (#opens:inames) (#pre1:slprop) (pre2:slprop) (#post1:a -> slprop) (post2:a -> slprop) (pf1 : slprop_equiv pre1 pre2) (pf2 : slprop_post_equiv post1 post2) (e:stt_atomic a #obs opens pre1 post1) : stt_atomic a #obs opens pre2 post2 = A.sub pre2 post2 e let sub_invs_stt_atomic (#a:Type u#a) (#obs:_) (#opens1 #opens2:inames) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #obs opens1 pre post) (_ : squash (inames_subset opens1 opens2)) : stt_atomic a #obs opens2 pre post = assert (Set.equal (Set.union opens1 opens2) opens2); A.weaken opens2 e let stt_ghost a pre post = Ghost.erased (act a emp_inames pre post) let return_ghost #a x p = Ghost.hide (return_atomic #a x p) let return_ghost_noeq #a x p = Ghost.hide (A.return #_ #p x) let bind_ghost (#a:Type u#a) (#b:Type u#b) (#pre1:slprop) (#post1:a -> slprop) (#post2:b -> slprop) (e1:stt_ghost a pre1 post1) (e2:(x:a -> stt_ghost b (post1 x) post2)) : stt_ghost b pre1 post2 = let e1 = Ghost.reveal e1 in let e2 = FStar.Ghost.Pull.pull (fun (x:a) -> Ghost.reveal (e2 x)) in Ghost.hide (A.bind e1 e2) let lift_ghost_neutral (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_ghost a pre post) (reveal_a:non_informative_witness a) : stt_atomic a #Neutral emp_inames pre post = admit() //This is the main axiom about ghost computations; in Steel, this axiom is implemented within the effect system let lift_neutral_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (e:stt_atomic a #Neutral emp_inames pre post) : stt_ghost a pre post = Ghost.hide e let frame_ghost (#a:Type u#a) (#pre:slprop) (#post:a -> slprop) (frame:slprop) (e:stt_ghost a pre post) : stt_ghost a (pre ** frame) (fun x -> post x ** frame) = Ghost.hide (A.frame (Ghost.reveal e)) let sub_ghost pre2 post2 pf1 pf2 e = Ghost.hide (A.sub pre2 post2 e) let noop (p:slprop) : stt_ghost unit p (fun _ -> p) = Ghost.hide (A.return #_ #(fun _ -> p) ()) let intro_pure (p:prop) (pf:squash p) : stt_ghost unit emp (fun _ -> pure p) = Ghost.hide (A.intro_pure p pf) let elim_pure (p:prop) : stt_ghost (squash p) (pure p) (fun _ -> emp) = Ghost.hide (A.elim_pure p) let intro_exists (#a:Type u#a) (p:a -> slprop) (x:erased a) : stt_ghost unit (p x) (fun _ -> exists* x. p x) = Ghost.hide (A.intro_exists p x) let elim_exists (#a:Type u#a) (p:a -> slprop) : stt_ghost (erased a) (exists* x. p x) (fun x -> p x) = Ghost.hide (A.elim_exists p) let ghost_reveal (a:Type) (x:erased a) : stt_ghost a emp (fun y -> pure (reveal x == y)) = let m : stt_ghost a (pure (reveal x == reveal x)) (fun y -> pure (reveal x == y)) = Ghost.hide (A.return #_ #(fun y -> pure (reveal x == y)) (reveal x)) in pure_trivial (reveal x == reveal x) (); m let new_invariant (p:slprop) : stt_atomic (inv p) #Unobservable emp_inames p (fun _ -> emp) = A.new_invariant p let with_invariant (#a:Type) (#obs:_) (#fp:slprop) (#fp':a -> slprop) (#f_opens:inames) (#p:slprop) (i:inv p{not (mem_inv f_opens i)}) ($f:unit -> stt_atomic a #obs f_opens (p ** fp) (fun x -> p ** fp' x)) : stt_atomic a #obs (add_inv f_opens i) fp fp' = A.with_invariant i f let pts_to_not_null #a #p r v = Ghost.hide (A.pts_to_not_null #a #p r v) let alloc = A.alloc let read = A.read let write = A.write let share #a #pcm r v0 v1 = Ghost.hide (A.share r v0 v1) let gather #a #pcm r v0 v1 = Ghost.hide (A.gather r v0 v1) let witness #a #pcm r f v pf = Ghost.hide (A.witness r f v pf) let recall #a #pcm #fact r v w = Ghost.hide (A.recall r v w) let ghost_ref #a p = Ghost.erased (ref a p) let ghost_pts_to #a #p r v = pts_to r v let hide_ghost #a #pre #post (f:stt_ghost a pre post) : stt_ghost (erased a) pre (fun x -> post (reveal x)) = let f = Ghost.reveal f in Ghost.hide <| A.bind f (fun (r:a) -> A.return #(erased a) #(fun (x:erased a) -> post (reveal x)) (hide r)) let ghost_alloc #a #pcm x = hide_ghost (Ghost.hide <| A.alloc #a x) let ghost_read (#a:Type) (#p:pcm a) (r:ghost_ref 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}))) : stt_ghost (erased (v:a{compatible p x v /\ p.refine v})) (ghost_pts_to r x) (fun v -> ghost_pts_to r (f v)) = hide_ghost <| Ghost.hide <|A.read r x f let ghost_write r x y f = Ghost.hide (A.write r x y f)
{ "checked_file": "/", "dependencies": [ "PulseCore.InstantiatedSemantics.fsti.checked", "PulseCore.Action.fsti.checked", "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.Pull.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "PulseCore.Atomic.fst" }
[ { "abbrev": true, "full_module": "PulseCore.Preorder", "short_module": "PP" }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": true, "full_module": "PulseCore.Action", "short_module": "A" }, { "abbrev": true, "full_module": "PulseCore.InstantiatedSemantics", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Observability", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.Action", "short_module": null }, { "abbrev": false, "full_module": "PulseCore.InstantiatedSemantics", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: PulseCore.Atomic.ghost_ref pcm -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a -> PulseCore.Atomic.stt_ghost (Prims.squash (FStar.PCM.composable pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1))) (PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v0) ** PulseCore.Atomic.ghost_pts_to r (FStar.Ghost.reveal v1)) (fun _ -> PulseCore.Atomic.ghost_pts_to r (FStar.PCM.op pcm (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1)))
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "PulseCore.Atomic.ghost_ref", "FStar.Ghost.erased", "FStar.Ghost.hide", "PulseCore.Action.act", "Prims.squash", "FStar.PCM.composable", "FStar.Ghost.reveal", "PulseCore.Action.emp_inames", "PulseCore.InstantiatedSemantics.op_Star_Star", "PulseCore.Atomic.ghost_pts_to", "FStar.PCM.op", "PulseCore.InstantiatedSemantics.slprop", "PulseCore.Action.gather", "PulseCore.Action.ref", "PulseCore.Atomic.stt_ghost" ]
[]
false
false
false
false
false
let ghost_gather r v0 v1 =
Ghost.hide (A.gather r v0 v1)
false
WasmSupport.fst
WasmSupport.betole16
val betole16 : x: FStar.UInt16.t -> FStar.UInt16.t
let betole16 (x: FStar.UInt16.t) = let open FStar.UInt16 in logor (logand (shift_right x 8ul) 0x00FFus) (logand (shift_left x 8ul) 0xFF00us)
{ "file_name": "runtime/WasmSupport.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 40, "end_line": 42, "start_col": 0, "start_line": 38 }
module WasmSupport open FStar.HyperStack.ST module C = FStar.Int.Cast module I64 = FStar.Int64 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module B = LowStar.Buffer open LowStar.BufferOps open FStar.Mul (* Functions implemented primitively in JS. No F* client should call those! *) assume val trap: Prims.string -> Stack unit (fun _ -> True) (fun _ _ _ -> False) (* Really not meant to be called by F* clients... *) assume val malloc: U32.t -> Stack U32.t (fun _ -> False) (fun _ _ _ -> False) (* Functions that the code-generator expects to find, either at the Ast, CFlat * or Wasm levels. In SimplifyWasm.ml, we prefix these with their module (before * "to_c_names". After that, e.g. in CFlatToWasm.ml, we can refer to them with * their short names, e.g. align_64. *) (* Round up to the nearest multiple of 64. *) let align_64 (x: U32.t): Tot U32.t = if not ( U32.((x &^ 0x07ul) =^ 0ul) ) then U32.( (x &^ lognot 0x07ul) +%^ 0x08ul ) else x (* Non-zero sizes are not supported, period. *) let check_buffer_size (s: U32.t): Stack unit (fun _-> True) (fun _ _ _ -> True) = if U32.( s =^ 0ul ) then trap "Zero-sized arrays are not supported in C and in WASM either. See WasmSupport.fst"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "WasmSupport.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt16.t -> FStar.UInt16.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t", "FStar.UInt16.logor", "FStar.UInt16.logand", "FStar.UInt16.shift_right", "FStar.UInt32.__uint_to_t", "FStar.UInt16.__uint_to_t", "FStar.UInt16.shift_left" ]
[]
false
false
false
true
false
let betole16 (x: FStar.UInt16.t) =
let open FStar.UInt16 in logor (logand (shift_right x 8ul) 0x00FFus) (logand (shift_left x 8ul) 0xFF00us)
false
WasmSupport.fst
WasmSupport.betole32
val betole32 : x: FStar.UInt32.t -> FStar.UInt32.t
let betole32 (x: U32.t) = let open U32 in logor (logor (logor (logand (shift_right x 24ul) 0x000000FFul) (logand (shift_right x 8ul) 0x0000FF00ul)) (logand (shift_left x 8ul) 0x00FF0000ul)) (logand (shift_left x 24ul) 0xFF000000ul)
{ "file_name": "runtime/WasmSupport.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 45, "end_line": 49, "start_col": 0, "start_line": 44 }
module WasmSupport open FStar.HyperStack.ST module C = FStar.Int.Cast module I64 = FStar.Int64 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module B = LowStar.Buffer open LowStar.BufferOps open FStar.Mul (* Functions implemented primitively in JS. No F* client should call those! *) assume val trap: Prims.string -> Stack unit (fun _ -> True) (fun _ _ _ -> False) (* Really not meant to be called by F* clients... *) assume val malloc: U32.t -> Stack U32.t (fun _ -> False) (fun _ _ _ -> False) (* Functions that the code-generator expects to find, either at the Ast, CFlat * or Wasm levels. In SimplifyWasm.ml, we prefix these with their module (before * "to_c_names". After that, e.g. in CFlatToWasm.ml, we can refer to them with * their short names, e.g. align_64. *) (* Round up to the nearest multiple of 64. *) let align_64 (x: U32.t): Tot U32.t = if not ( U32.((x &^ 0x07ul) =^ 0ul) ) then U32.( (x &^ lognot 0x07ul) +%^ 0x08ul ) else x (* Non-zero sizes are not supported, period. *) let check_buffer_size (s: U32.t): Stack unit (fun _-> True) (fun _ _ _ -> True) = if U32.( s =^ 0ul ) then trap "Zero-sized arrays are not supported in C and in WASM either. See WasmSupport.fst" let betole16 (x: FStar.UInt16.t) = let open FStar.UInt16 in logor (logand (shift_right x 8ul) 0x00FFus) (logand (shift_left x 8ul) 0xFF00us)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "WasmSupport.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> FStar.UInt32.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "FStar.UInt32.logor", "FStar.UInt32.logand", "FStar.UInt32.shift_right", "FStar.UInt32.__uint_to_t", "FStar.UInt32.shift_left" ]
[]
false
false
false
true
false
let betole32 (x: U32.t) =
let open U32 in logor (logor (logor (logand (shift_right x 24ul) 0x000000FFul) (logand (shift_right x 8ul) 0x0000FF00ul)) (logand (shift_left x 8ul) 0x00FF0000ul)) (logand (shift_left x 24ul) 0xFF000000ul)
false
GT.fst
GT.t_return
val t_return (#a: _) (x: a) : m a T
val t_return (#a: _) (x: a) : m a T
let t_return #a (x:a) : m a T = (fun () -> x)
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 20, "start_col": 0, "start_line": 20 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> GT.m a GT.T
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "GT.m", "GT.T" ]
[]
false
false
false
true
false
let t_return #a (x: a) : m a T =
(fun () -> x)
false
GT.fst
GT.d_return
val d_return (#a: _) (x: a) : m a D
val d_return (#a: _) (x: a) : m a D
let d_return #a (x:a) : m a D = raise_val (fun () -> x)
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 22, "start_col": 0, "start_line": 22 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> GT.m a GT.D
Prims.Tot
[ "total" ]
[]
[ "FStar.Universe.raise_val", "Prims.unit", "GT.m", "GT.D" ]
[]
false
false
false
true
false
let d_return #a (x: a) : m a D =
raise_val (fun () -> x)
false
GT.fst
GT.g_return
val g_return (#a: _) (x: a) : m a G
val g_return (#a: _) (x: a) : m a G
let g_return #a (x:a) : m a G = (fun () -> x)
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 21, "start_col": 0, "start_line": 21 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> GT.m a GT.G
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "GT.m", "GT.G" ]
[]
false
false
false
true
false
let g_return #a (x: a) : m a G =
(fun () -> x)
false
GT.fst
GT.t_bind
val t_bind (#a #b: _) (c: m a T) (f: (a -> m b T)) : m b T
val t_bind (#a #b: _) (c: m a T) (f: (a -> m b T)) : m b T
let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) ()
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 30, "start_col": 0, "start_line": 30 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: GT.m a GT.T -> f: (_: a -> GT.m b GT.T) -> GT.m b GT.T
Prims.Tot
[ "total" ]
[]
[ "GT.m", "GT.T", "Prims.unit" ]
[]
false
false
false
true
false
let t_bind #a #b (c: m a T) (f: (a -> m b T)) : m b T =
fun () -> f (c ()) ()
false
GT.fst
GT.g_bind
val g_bind (#a #b: _) (c: m a G) (f: (a -> m b G)) : m b G
val g_bind (#a #b: _) (c: m a G) (f: (a -> m b G)) : m b G
let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) ()
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 31, "start_col": 0, "start_line": 31 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: GT.m a GT.G -> f: (_: a -> GT.m b GT.G) -> GT.m b GT.G
Prims.Tot
[ "total" ]
[]
[ "GT.m", "GT.G", "Prims.unit" ]
[]
false
false
false
true
false
let g_bind #a #b (c: m a G) (f: (a -> m b G)) : m b G =
fun () -> f (c ()) ()
false
GT.fst
GT.d_bind
val d_bind (#a #b: _) (c: m a D) (f: (a -> m b D)) : m b D
val d_bind (#a #b: _) (c: m a D) (f: (a -> m b D)) : m b D
let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ())
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 33, "start_col": 0, "start_line": 32 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: GT.m a GT.D -> f: (_: a -> GT.m b GT.D) -> GT.m b GT.D
Prims.Tot
[ "total" ]
[]
[ "GT.m", "GT.D", "FStar.Universe.raise_val", "Prims.unit", "FStar.Universe.downgrade_val", "FStar.Universe.raise_t" ]
[]
false
false
false
true
false
let d_bind #a #b (c: m a D) (f: (a -> m b D)) : m b D =
raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ())
false
GT.fst
GT.subcomp
val subcomp (a: Type) (i: idx) (f: m a i) : m a i
val subcomp (a: Type) (i: idx) (f: m a i) : m a i
let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 54, "start_col": 0, "start_line": 54 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> i: GT.idx -> f: GT.m a i -> GT.m a i
Prims.Tot
[ "total" ]
[]
[ "GT.idx", "GT.m" ]
[]
false
false
false
false
false
let subcomp (a: Type) (i: idx) (f: m a i) : m a i =
f
false
GT.fst
GT.t1_d
val t1_d: Prims.unit -> Dv (list int)
val t1_d: Prims.unit -> Dv (list int)
let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) ()
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 106, "end_line": 52, "start_col": 0, "start_line": 52 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Dv (Prims.list Prims.int)
FStar.Pervasives.Dv
[]
[]
[ "Prims.unit", "FStar.Universe.downgrade_val", "Prims.list", "Prims.int", "GT.r_map", "GT.D", "FStar.Universe.raise_val", "Prims.op_Addition", "GT.m", "Prims.Cons", "Prims.Nil" ]
[]
false
true
false
false
false
let t1_d () : Dv (list int) =
downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1; 2; 3; 4]) ()
false
GT.fst
GT.t1_t
val t1_t: Prims.unit -> Tot (list int)
val t1_t: Prims.unit -> Tot (list int)
let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] ()
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 79, "end_line": 50, "start_col": 0, "start_line": 50 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> Prims.list Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "GT.r_map", "GT.T", "Prims.int", "Prims.op_Addition", "Prims.Cons", "Prims.Nil", "Prims.list" ]
[]
false
false
false
true
false
let t1_t () : Tot (list int) =
r_map #T (fun x -> fun () -> x + 1) [1; 2; 3; 4] ()
false
GT.fst
GT.t1_g
val t1_g: Prims.unit -> GTot (list int)
val t1_g: Prims.unit -> GTot (list int)
let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] ()
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 80, "end_line": 51, "start_col": 0, "start_line": 51 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> Prims.GTot (Prims.list Prims.int)
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.unit", "GT.r_map", "GT.G", "Prims.int", "Prims.op_Addition", "Prims.Cons", "Prims.Nil", "Prims.list" ]
[]
false
false
false
false
false
let t1_g () : GTot (list int) =
r_map #G (fun x -> fun () -> x + 1) [1; 2; 3; 4] ()
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.valid_sum_intro
val valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_enum_key p (sum_enum t)) h input pos /\ (let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos)) )) (ensures (let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload)))
val valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_enum_key p (sum_enum t)) h input pos /\ (let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos)) )) (ensures (let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload)))
let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos)
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 55, "end_line": 237, "start_col": 0, "start_line": 209 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 8, "max_fuel": 2, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 256, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> t: LowParse.Spec.Sum.sum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.sum_repr_type t) -> pc: (x: LowParse.Spec.Sum.sum_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.sum_type_of_tag t x))) -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.Enum.parse_enum_key p (LowParse.Spec.Sum.sum_enum t)) h input pos /\ (let k = LowParse.Low.Base.Spec.contents (LowParse.Spec.Enum.parse_enum_key p (LowParse.Spec.Sum.sum_enum t)) h input pos in LowParse.Low.Base.Spec.valid (FStar.Pervasives.dsnd (pc k)) h input (LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.Enum.parse_enum_key p (LowParse.Spec.Sum.sum_enum t)) h input pos))) (ensures (let k = LowParse.Low.Base.Spec.contents (LowParse.Spec.Enum.parse_enum_key p (LowParse.Spec.Sum.sum_enum t)) h input pos in let pos_payload = LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.Enum.parse_enum_key p (LowParse.Spec.Sum.sum_enum t)) h input pos in LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Sum.parse_sum t p pc) h input pos (LowParse.Spec.Sum.synth_sum_case t k (LowParse.Low.Base.Spec.contents (FStar.Pervasives.dsnd (pc k)) h input pos_payload) ) (LowParse.Low.Base.Spec.get_valid_pos (FStar.Pervasives.dsnd (pc k)) h input pos_payload )))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Spec.Sum.sum", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.sum_repr_type", "LowParse.Spec.Sum.sum_key", "Prims.dtuple2", "LowParse.Spec.Sum.sum_type_of_tag", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Spec.Sum.parse_sum_eq", "LowParse.Slice.bytes_of_slice_from", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Sum.parse_sum_kind", "LowParse.Spec.Sum.sum_type", "LowParse.Spec.Sum.parse_sum", "Prims.__proj__Mkdtuple2__item___1", "FStar.Pervasives.dsnd", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Sum.sum_key_type", "LowParse.Spec.Sum.sum_enum", "LowParse.Spec.Enum.parse_enum_key", "LowParse.Low.Base.Spec.contents", "Prims.l_and", "LowParse.Low.Base.Spec.valid", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Sum.synth_sum_case", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_enum_key p (sum_enum t)) h input pos /\ (let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos)) )) (ensures (let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload))) =
valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos)
false
A.fst
A.main
val main: argc:Int32.t{Int32.v argc > 0} -> argv:Buffer.buffer string{Buffer.length argv == Int32.v argc} -> Stack Int32.t (requires (fun h -> True)) (ensures (fun h _ h' -> True))
val main: argc:Int32.t{Int32.v argc > 0} -> argv:Buffer.buffer string{Buffer.length argv == Int32.v argc} -> Stack Int32.t (requires (fun h -> True)) (ensures (fun h _ h' -> True))
let main argc argv = if not (B.validate (Cast.int32_to_uint32 argc) argv) then 1l else 0l
{ "file_name": "examples/sample_project/A.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 24, "start_col": 0, "start_line": 21 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module A open FStar.HyperStack.ST open FStar.Buffer open FStar.Int.Cast
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Buffer.fst.checked", "B.fsti.checked" ], "interface_file": true, "source_file": "A.fst" }
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "FStar.Int.Cast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
argc: FStar.Int32.t{FStar.Int32.v argc > 0} -> argv: FStar.Buffer.buffer Prims.string {FStar.Buffer.length argv == FStar.Int32.v argc} -> FStar.HyperStack.ST.Stack FStar.Int32.t
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.Int32.t", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Int32.v", "FStar.Buffer.buffer", "Prims.string", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.Int.size", "FStar.Int32.n", "FStar.Buffer.length", "FStar.Int32.__int_to_t", "Prims.bool", "Prims.op_Negation", "B.validate", "FStar.Int.Cast.int32_to_uint32" ]
[]
false
true
false
false
false
let main argc argv =
if not (B.validate (Cast.int32_to_uint32 argc) argv) then 1l else 0l
false
WasmSupport.fst
WasmSupport.betole64
val betole64 : x: FStar.UInt64.t -> FStar.UInt64.t
let betole64 (x: U64.t) = let low = C.uint32_to_uint64 (betole32 (C.uint64_to_uint32 x)) in let high = C.uint32_to_uint64 (betole32 (C.uint64_to_uint32 (U64.shift_right x 32ul))) in U64.logor (U64.shift_left low 32ul) high
{ "file_name": "runtime/WasmSupport.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 42, "end_line": 54, "start_col": 0, "start_line": 51 }
module WasmSupport open FStar.HyperStack.ST module C = FStar.Int.Cast module I64 = FStar.Int64 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module B = LowStar.Buffer open LowStar.BufferOps open FStar.Mul (* Functions implemented primitively in JS. No F* client should call those! *) assume val trap: Prims.string -> Stack unit (fun _ -> True) (fun _ _ _ -> False) (* Really not meant to be called by F* clients... *) assume val malloc: U32.t -> Stack U32.t (fun _ -> False) (fun _ _ _ -> False) (* Functions that the code-generator expects to find, either at the Ast, CFlat * or Wasm levels. In SimplifyWasm.ml, we prefix these with their module (before * "to_c_names". After that, e.g. in CFlatToWasm.ml, we can refer to them with * their short names, e.g. align_64. *) (* Round up to the nearest multiple of 64. *) let align_64 (x: U32.t): Tot U32.t = if not ( U32.((x &^ 0x07ul) =^ 0ul) ) then U32.( (x &^ lognot 0x07ul) +%^ 0x08ul ) else x (* Non-zero sizes are not supported, period. *) let check_buffer_size (s: U32.t): Stack unit (fun _-> True) (fun _ _ _ -> True) = if U32.( s =^ 0ul ) then trap "Zero-sized arrays are not supported in C and in WASM either. See WasmSupport.fst" let betole16 (x: FStar.UInt16.t) = let open FStar.UInt16 in logor (logand (shift_right x 8ul) 0x00FFus) (logand (shift_left x 8ul) 0xFF00us) let betole32 (x: U32.t) = let open U32 in logor (logor (logor (logand (shift_right x 24ul) 0x000000FFul) (logand (shift_right x 8ul) 0x0000FF00ul)) (logand (shift_left x 8ul) 0x00FF0000ul)) (logand (shift_left x 24ul) 0xFF000000ul)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "WasmSupport.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt64.t -> FStar.UInt64.t
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t", "FStar.UInt64.logor", "FStar.UInt64.shift_left", "FStar.UInt32.__uint_to_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt64.v", "FStar.UInt32.v", "WasmSupport.betole32", "FStar.Int.Cast.uint64_to_uint32", "FStar.UInt64.shift_right", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "FStar.Int.Cast.uint32_to_uint64" ]
[]
false
false
false
true
false
let betole64 (x: U64.t) =
let low = C.uint32_to_uint64 (betole32 (C.uint64_to_uint32 x)) in let high = C.uint32_to_uint64 (betole32 (C.uint64_to_uint32 (U64.shift_right x 32ul))) in U64.logor (U64.shift_left low 32ul) high
false
GT.fst
GT.app
val app (#a #b #i: _) (f: (a -> GTD b i)) (x: a) : GTD b i
val app (#a #b #i: _) (f: (a -> GTD b i)) (x: a) : GTD b i
let app #a #b #i (f : a -> GTD b i) (x : a) : GTD b i = f x
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 92, "start_col": 0, "start_line": 92 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) () let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f let if_then_else (a:Type) (i:idx) (f : m a i) (g : m a i) (b : bool) : Type = m a i // GM: Would be nice to not have to use all explicit args everywhere, // and to get better errors especially when args are out of order, // e.g. the [idx] in [return] needs to come after [x], otherwise // we get an assertion failure trying to prove [forall (a: Type). idx == a]. reifiable reflectable effect { GTD (a:Type) ([@@@ effect_param] _:idx) with {repr = m; return; bind; subcomp; if_then_else} } let lift_pure_gtd (a:Type) (wp : pure_wp a) (i : idx) (f : unit -> PURE a wp) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) = //f // GM: Surprised that this works actually... I expected that I would need to // case analyze [i]. // GM: ok not anymore FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a)) sub_effect PURE ~> GTD = lift_pure_gtd let rec map #a #b #i (f : a -> GTD b i) (xs : list a) : GTD (list b) i = match xs with | [] -> [] | x::xs -> (f x)::(map f xs)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> GT.GTD b) -> x: a -> GT.GTD b
GT.GTD
[]
[]
[ "GT.idx" ]
[]
false
true
false
false
false
let app #a #b #i (f: (a -> GTD b i)) (x: a) : GTD b i =
f x
false
GT.fst
GT.labs0
val labs0 (#i: _) (n: int) : GTD int i
val labs0 (#i: _) (n: int) : GTD int i
let labs0 #i (n:int) : GTD int i = if n < 0 then -n else n
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 8, "end_line": 113, "start_col": 0, "start_line": 110 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) () let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f let if_then_else (a:Type) (i:idx) (f : m a i) (g : m a i) (b : bool) : Type = m a i // GM: Would be nice to not have to use all explicit args everywhere, // and to get better errors especially when args are out of order, // e.g. the [idx] in [return] needs to come after [x], otherwise // we get an assertion failure trying to prove [forall (a: Type). idx == a]. reifiable reflectable effect { GTD (a:Type) ([@@@ effect_param] _:idx) with {repr = m; return; bind; subcomp; if_then_else} } let lift_pure_gtd (a:Type) (wp : pure_wp a) (i : idx) (f : unit -> PURE a wp) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) = //f // GM: Surprised that this works actually... I expected that I would need to // case analyze [i]. // GM: ok not anymore FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a)) sub_effect PURE ~> GTD = lift_pure_gtd let rec map #a #b #i (f : a -> GTD b i) (xs : list a) : GTD (list b) i = match xs with | [] -> [] | x::xs -> (f x)::(map f xs) let app #a #b #i (f : a -> GTD b i) (x : a) : GTD b i = f x // todo: use map/app from tot context and prove that it does what it's meant to do open FStar.Tactics.V2 let rec appn #a #i (n:nat) (f : a -> GTD a i) (x : a) : GTD a i = match n with | 0 -> x | _ -> begin appn (n-1) f (f x) end [@@expect_failure] let test #a #i (n:int) : GTD nat i = let r = app abs n in r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.int -> GT.GTD Prims.int
GT.GTD
[]
[]
[ "GT.idx", "Prims.int", "Prims.op_LessThan", "Prims.op_Minus", "Prims.bool" ]
[]
false
true
false
false
false
let labs0 #i (n: int) : GTD int i =
if n < 0 then - n else n
false
Pulse.Checker.Return.fst
Pulse.Checker.Return.check_tot_or_ghost_term
val check_tot_or_ghost_term (g: env) (e t: term) (c: option ctag) : T.Tac (c: ctag & e: term & typing g e (eff_of_ctag c) t)
val check_tot_or_ghost_term (g: env) (e t: term) (c: option ctag) : T.Tac (c: ctag & e: term & typing g e (eff_of_ctag c) t)
let check_tot_or_ghost_term (g:env) (e:term) (t:term) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = let (| e, eff, d |) = check_term_at_type g e t in check_effect d c
{ "file_name": "lib/steel/pulse/Pulse.Checker.Return.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 18, "end_line": 52, "start_col": 0, "start_line": 49 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Return open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory let check_effect (#g:env) (#e:term) (#eff:T.tot_or_ghost) (#t:term) (d:typing g e eff t) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = match c, eff with | None, T.E_Total -> (| STT_Atomic, e, d |) | None, T.E_Ghost -> (| STT_Ghost, e, d |) | Some STT_Ghost, T.E_Total -> (| STT_Atomic, e, d |) | Some STT_Ghost, T.E_Ghost -> (| STT_Ghost, e, d |) | _, T.E_Total -> (| STT_Atomic, e, d |) | _ -> fail g (Some e.range) "Expected a total term, but this term has Ghost effect"
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Return.fst" }
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> e: Pulse.Syntax.Base.term -> t: Pulse.Syntax.Base.term -> c: FStar.Pervasives.Native.option Pulse.Syntax.Base.ctag -> FStar.Tactics.Effect.Tac (FStar.Pervasives.dtuple3 Pulse.Syntax.Base.ctag (fun _ -> Pulse.Syntax.Base.term) (fun c e -> Pulse.Typing.typing g e (Pulse.Typing.eff_of_ctag c) t))
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.ctag", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "Pulse.Typing.typing", "Pulse.Checker.Return.check_effect", "FStar.Pervasives.dtuple3", "Pulse.Typing.eff_of_ctag", "Pulse.Checker.Pure.check_term_at_type" ]
[]
false
true
false
false
false
let check_tot_or_ghost_term (g: env) (e t: term) (c: option ctag) : T.Tac (c: ctag & e: term & typing g e (eff_of_ctag c) t) =
let (| e , eff , d |) = check_term_at_type g e t in check_effect d c
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.valid_dsum_elim_known
val valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)))) (ensures (valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ (let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ (let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload)))))
val valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)))) (ensures (valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ (let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ (let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload)))))
let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 46, "end_line": 1334, "start_col": 0, "start_line": 1300 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> t: LowParse.Spec.Sum.dsum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.dsum_repr_type t) -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.Sum.parse_dsum t p f g) h input pos /\ Known? (LowParse.Spec.Sum.dsum_tag_of_data t (LowParse.Low.Base.Spec.contents (LowParse.Spec.Sum.parse_dsum t p f g) h input pos))) (ensures LowParse.Low.Base.Spec.valid (LowParse.Spec.Enum.parse_maybe_enum_key p (LowParse.Spec.Sum.dsum_enum t)) h input pos /\ (let k' = LowParse.Low.Base.Spec.contents (LowParse.Spec.Enum.parse_maybe_enum_key p (LowParse.Spec.Sum.dsum_enum t)) h input pos in let pos_payload = LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.Enum.parse_maybe_enum_key p (LowParse.Spec.Sum.dsum_enum t)) h input pos in Known? k' /\ (let _ = k' in (let LowParse.Spec.Enum.Known #_ #_ #_ k = _ in LowParse.Low.Base.Spec.valid (FStar.Pervasives.dsnd (f k)) h input pos_payload /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Sum.parse_dsum t p f g) h input pos (LowParse.Spec.Sum.synth_dsum_case t (LowParse.Spec.Enum.Known k) (LowParse.Low.Base.Spec.contents (FStar.Pervasives.dsnd (f k)) h input pos_payload)) (LowParse.Low.Base.Spec.get_valid_pos (FStar.Pervasives.dsnd (f k)) h input pos_payload)) <: Prims.logical)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Spec.Sum.dsum", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Spec.Enum.enum_key", "LowParse.Spec.Sum.dsum_key_type", "LowParse.Spec.Sum.dsum_enum", "LowParse.Low.Base.Spec.valid_facts", "Prims.__proj__Mkdtuple2__item___1", "FStar.Pervasives.dsnd", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Spec.Enum.maybe_enum_key", "LowParse.Spec.Enum.parse_maybe_enum_key", "Prims.unit", "LowParse.Low.Base.Spec.contents", "LowParse.Spec.Sum.parse_dsum_eq", "LowParse.Slice.bytes_of_slice_from", "LowParse.Spec.Sum.parse_dsum_kind", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.parse_dsum", "Prims.l_and", "LowParse.Low.Base.Spec.valid", "Prims.b2t", "LowParse.Spec.Enum.uu___is_Known", "LowParse.Spec.Sum.dsum_tag_of_data", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Sum.synth_dsum_case", "LowParse.Spec.Enum.Known", "Prims.logical", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)))) (ensures (valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ (let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ (let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload))))) =
valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload
false
Pulse.Checker.Return.fst
Pulse.Checker.Return.compute_tot_or_ghost_term_type_and_u
val compute_tot_or_ghost_term_type_and_u (g: env) (e: term) (c: option ctag) : T.Tac (result_of_typing g)
val compute_tot_or_ghost_term_type_and_u (g: env) (e: term) (c: option ctag) : T.Tac (result_of_typing g)
let compute_tot_or_ghost_term_type_and_u (g:env) (e:term) (c:option ctag) : T.Tac (result_of_typing g) = let (| t, eff, ty, (| u, ud |), d |) = compute_term_type_and_u g e in let (| c, e, d |) = check_effect d c in R c e u ty ud d
{ "file_name": "lib/steel/pulse/Pulse.Checker.Return.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 69, "start_col": 0, "start_line": 65 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Return open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory let check_effect (#g:env) (#e:term) (#eff:T.tot_or_ghost) (#t:term) (d:typing g e eff t) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = match c, eff with | None, T.E_Total -> (| STT_Atomic, e, d |) | None, T.E_Ghost -> (| STT_Ghost, e, d |) | Some STT_Ghost, T.E_Total -> (| STT_Atomic, e, d |) | Some STT_Ghost, T.E_Ghost -> (| STT_Ghost, e, d |) | _, T.E_Total -> (| STT_Atomic, e, d |) | _ -> fail g (Some e.range) "Expected a total term, but this term has Ghost effect" let check_tot_or_ghost_term (g:env) (e:term) (t:term) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = let (| e, eff, d |) = check_term_at_type g e t in check_effect d c noeq type result_of_typing (g:env) = | R : c:ctag -> t:term -> u:universe -> ty:term -> universe_of g ty u -> typing g t (eff_of_ctag c) ty -> result_of_typing g
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Return.fst" }
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> e: Pulse.Syntax.Base.term -> c: FStar.Pervasives.Native.option Pulse.Syntax.Base.ctag -> FStar.Tactics.Effect.Tac (Pulse.Checker.Return.result_of_typing g)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.ctag", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "Pulse.Syntax.Base.universe", "Pulse.Typing.universe_of", "Pulse.Typing.typing", "Pulse.Typing.eff_of_ctag", "Pulse.Checker.Return.R", "Pulse.Checker.Return.result_of_typing", "FStar.Pervasives.dtuple3", "Pulse.Checker.Return.check_effect", "FStar.Pervasives.dtuple5", "Prims.dtuple2", "Pulse.Checker.Pure.compute_term_type_and_u" ]
[]
false
true
false
false
false
let compute_tot_or_ghost_term_type_and_u (g: env) (e: term) (c: option ctag) : T.Tac (result_of_typing g) =
let (| t , eff , ty , (| u , ud |) , d |) = compute_term_type_and_u g e in let (| c , e , d |) = check_effect d c in R c e u ty ud d
false
WasmSupport.fst
WasmSupport.memzero
val memzero (x: B.buffer UInt8.t) (len sz: UInt32.t) : Stack unit (requires fun h0 -> B.live h0 x /\ sz <> 0ul /\ B.length x = U32.v len * U32.v sz) (ensures (fun h0 _ h1 -> let open B in modifies (loc_buffer x) h0 h1))
val memzero (x: B.buffer UInt8.t) (len sz: UInt32.t) : Stack unit (requires fun h0 -> B.live h0 x /\ sz <> 0ul /\ B.length x = U32.v len * U32.v sz) (ensures (fun h0 _ h1 -> let open B in modifies (loc_buffer x) h0 h1))
let memzero (x: B.buffer UInt8.t) (len: UInt32.t) (sz: UInt32.t): Stack unit (requires fun h0 -> B.live h0 x /\ sz <> 0ul /\ B.length x = U32.v len * U32.v sz) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer x) h0 h1))) = if len `U32.gte` (0xfffffffful `U32.div` sz) then trap "Overflow in memzero; see WasmSupport.fst"; let n_bytes = U32.mul len sz in let h0 = FStar.HyperStack.ST.get () in C.Loops.for 0ul n_bytes (fun h _ -> B.live h x /\ B.(modifies (loc_buffer x) h0 h) ) (fun i -> x.(i) <- 0uy )
{ "file_name": "runtime/WasmSupport.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 3, "end_line": 69, "start_col": 0, "start_line": 56 }
module WasmSupport open FStar.HyperStack.ST module C = FStar.Int.Cast module I64 = FStar.Int64 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module B = LowStar.Buffer open LowStar.BufferOps open FStar.Mul (* Functions implemented primitively in JS. No F* client should call those! *) assume val trap: Prims.string -> Stack unit (fun _ -> True) (fun _ _ _ -> False) (* Really not meant to be called by F* clients... *) assume val malloc: U32.t -> Stack U32.t (fun _ -> False) (fun _ _ _ -> False) (* Functions that the code-generator expects to find, either at the Ast, CFlat * or Wasm levels. In SimplifyWasm.ml, we prefix these with their module (before * "to_c_names". After that, e.g. in CFlatToWasm.ml, we can refer to them with * their short names, e.g. align_64. *) (* Round up to the nearest multiple of 64. *) let align_64 (x: U32.t): Tot U32.t = if not ( U32.((x &^ 0x07ul) =^ 0ul) ) then U32.( (x &^ lognot 0x07ul) +%^ 0x08ul ) else x (* Non-zero sizes are not supported, period. *) let check_buffer_size (s: U32.t): Stack unit (fun _-> True) (fun _ _ _ -> True) = if U32.( s =^ 0ul ) then trap "Zero-sized arrays are not supported in C and in WASM either. See WasmSupport.fst" let betole16 (x: FStar.UInt16.t) = let open FStar.UInt16 in logor (logand (shift_right x 8ul) 0x00FFus) (logand (shift_left x 8ul) 0xFF00us) let betole32 (x: U32.t) = let open U32 in logor (logor (logor (logand (shift_right x 24ul) 0x000000FFul) (logand (shift_right x 8ul) 0x0000FF00ul)) (logand (shift_left x 8ul) 0x00FF0000ul)) (logand (shift_left x 24ul) 0xFF000000ul) let betole64 (x: U64.t) = let low = C.uint32_to_uint64 (betole32 (C.uint64_to_uint32 x)) in let high = C.uint32_to_uint64 (betole32 (C.uint64_to_uint32 (U64.shift_right x 32ul))) in U64.logor (U64.shift_left low 32ul) high
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "WasmSupport.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: LowStar.Buffer.buffer FStar.UInt8.t -> len: FStar.UInt32.t -> sz: FStar.UInt32.t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "LowStar.Buffer.buffer", "FStar.UInt8.t", "FStar.UInt32.t", "C.Loops.for", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowStar.BufferOps.op_Array_Assignment", "FStar.UInt8.__uint_to_t", "Prims.unit", "FStar.HyperStack.ST.get", "FStar.UInt32.mul", "FStar.UInt32.gte", "FStar.UInt32.div", "WasmSupport.trap", "Prims.bool", "Prims.op_disEquality", "Prims.op_Equality", "Prims.int", "LowStar.Monotonic.Buffer.length", "FStar.Mul.op_Star" ]
[]
false
true
false
false
false
let memzero (x: B.buffer UInt8.t) (len sz: UInt32.t) : Stack unit (requires fun h0 -> B.live h0 x /\ sz <> 0ul /\ B.length x = U32.v len * U32.v sz) (ensures (fun h0 _ h1 -> let open B in modifies (loc_buffer x) h0 h1)) =
if len `U32.gte` (0xfffffffful `U32.div` sz) then trap "Overflow in memzero; see WasmSupport.fst"; let n_bytes = U32.mul len sz in let h0 = FStar.HyperStack.ST.get () in C.Loops.for 0ul n_bytes (fun h _ -> B.live h x /\ B.(modifies (loc_buffer x) h0 h)) (fun i -> x.(i) <- 0uy)
false
GT.fst
GT.return
val return (a: Type) (x: a) (i: idx) : m a i
val return (a: Type) (x: a) (i: idx) : m a i
let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 28, "start_col": 0, "start_line": 24 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> i: GT.idx -> GT.m a i
Prims.Tot
[ "total" ]
[]
[ "GT.idx", "GT.t_return", "GT.g_return", "GT.d_return", "GT.m" ]
[]
false
false
false
false
false
let return (a: Type) (x: a) (i: idx) : m a i =
match i with | T -> t_return x | G -> g_return x | D -> d_return x
false
WorkingWithSquashedProofs.fst
WorkingWithSquashedProofs.valid_baz_alt_alt
val valid_baz_alt_alt (a: Type) (x: a) : GTot (squash (baz a x))
val valid_baz_alt_alt (a: Type) (x: a) : GTot (squash (baz a x))
let valid_baz_alt_alt (a:Type) (x:a) : GTot (squash (baz a x)) = let fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.join_squash (elim_squash_or fb (lemma_as_squash (c_foo_baz x)) (lemma_as_squash (c_bar_baz x)))
{ "file_name": "examples/misc/WorkingWithSquashedProofs.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 141, "start_col": 0, "start_line": 135 }
(* Copyright 2008-2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module WorkingWithSquashedProofs open FStar.Squash //Mixing squashed an constructive proofs //It's a bit bureaucratic and technical ... I wish this part of F* were simpler //There's a bunch of redundancy between Lemma, squash, GTot, prop, etc. //which is always confusing. //Suppose I have some predicates, it could be that inductive type about //interleaving that you had assume val foo (a:Type) (x:a) : Type assume val bar (a:Type) (x:a) : Type //And let's say I have a way of proving some Lemma based on a proof of this `pred` assume val foo_pf_implies_bar (a:Type) (x:a) (pf:foo a x) : Lemma (bar a x) //Now, if I have `foo` in a refinement, I can still prove `bar, like so //One can use FStar.Squash.bind_squash for that, but it takes a couple of steps //expect_failure is an attribute that tells F* that this next definition will fail [@expect_failure] //but this doesn't quite work because `bind_squash` expects a GTot function but we are giving it a Lemma, which isn't identical let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = let s : squash (foo a x) = () in FStar.Squash.bind_squash #(foo a x) #(bar a x) s (foo_pf_implies_bar a x) //So, to make it work, we need to turn a lemma into a GTot function returning a squash let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x:a) : GTot (squash b) = lem x //Now, I can use FStar.Squash.bind_squash to complete the proof let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = FStar.Squash.bind_squash () (lemma_as_squash (foo_pf_implies_bar a x)) // Another example, this time with disjunctions // Say I have a lemma proving a disjunction assume val foo_or_bar (#a:_) (x:a) : Lemma (foo a x \/ bar a x) assume val baz (a:Type) (x:a) : Type // And let's say I have separate lemmas proving // foo implies baz // and bar impliez baz assume val foo_baz (#a:_) (x:a) : Lemma (requires foo a x) (ensures baz a x) assume val bar_baz (#a:_) (x:a) : Lemma (requires bar a x) (ensures baz a x) let valid_baz (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> // let sf = FStar.Squash.return_squash f in foo_baz x | Prims.Right b -> // let sg = FStar.Squash.return_squash b in bar_baz x in s_baz)) // And here's a variant where the lemmas I want to call // expect proof terms of foo or bar assume val c_foo_baz (#a:_) (x:a) (_:foo a x) : Lemma (ensures baz a x) assume val c_bar_baz (#a:_) (x:a) (_:bar a x) : Lemma (ensures baz a x) let valid_baz_alt (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> c_foo_baz x f | Prims.Right b -> c_bar_baz x b in s_baz)) //We can wrap that up into a combinator like so // See also FStar.Classical.or_elim which is a variant of this let elim_squash_or (#r:_) (#p #q:_) (f:squash (p \/ q)) (left: p -> GTot r) (right: q -> GTot r) : GTot (squash r) = FStar.Squash.bind_squash #_ #r f (fun pq -> FStar.Squash.bind_squash pq (fun c -> match c with | Prims.Left x -> FStar.Squash.return_squash (left x) | Prims.Right x -> FStar.Squash.return_squash (right x)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "WorkingWithSquashedProofs.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> Prims.GTot (Prims.squash (WorkingWithSquashedProofs.baz a x))
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Squash.join_squash", "WorkingWithSquashedProofs.baz", "WorkingWithSquashedProofs.elim_squash_or", "Prims.squash", "WorkingWithSquashedProofs.foo", "WorkingWithSquashedProofs.bar", "WorkingWithSquashedProofs.lemma_as_squash", "WorkingWithSquashedProofs.c_foo_baz", "WorkingWithSquashedProofs.c_bar_baz", "Prims.l_or", "WorkingWithSquashedProofs.foo_or_bar" ]
[]
false
false
true
false
false
let valid_baz_alt_alt (a: Type) (x: a) : GTot (squash (baz a x)) =
let fb:squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.join_squash (elim_squash_or fb (lemma_as_squash (c_foo_baz x)) (lemma_as_squash (c_bar_baz x)))
false
WasmSupport.fst
WasmSupport.check_buffer_size
val check_buffer_size (s: U32.t) : Stack unit (fun _ -> True) (fun _ _ _ -> True)
val check_buffer_size (s: U32.t) : Stack unit (fun _ -> True) (fun _ _ _ -> True)
let check_buffer_size (s: U32.t): Stack unit (fun _-> True) (fun _ _ _ -> True) = if U32.( s =^ 0ul ) then trap "Zero-sized arrays are not supported in C and in WASM either. See WasmSupport.fst"
{ "file_name": "runtime/WasmSupport.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 91, "end_line": 36, "start_col": 0, "start_line": 34 }
module WasmSupport open FStar.HyperStack.ST module C = FStar.Int.Cast module I64 = FStar.Int64 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module B = LowStar.Buffer open LowStar.BufferOps open FStar.Mul (* Functions implemented primitively in JS. No F* client should call those! *) assume val trap: Prims.string -> Stack unit (fun _ -> True) (fun _ _ _ -> False) (* Really not meant to be called by F* clients... *) assume val malloc: U32.t -> Stack U32.t (fun _ -> False) (fun _ _ _ -> False) (* Functions that the code-generator expects to find, either at the Ast, CFlat * or Wasm levels. In SimplifyWasm.ml, we prefix these with their module (before * "to_c_names". After that, e.g. in CFlatToWasm.ml, we can refer to them with * their short names, e.g. align_64. *) (* Round up to the nearest multiple of 64. *) let align_64 (x: U32.t): Tot U32.t = if not ( U32.((x &^ 0x07ul) =^ 0ul) ) then U32.( (x &^ lognot 0x07ul) +%^ 0x08ul ) else x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "C.Loops.fst.checked" ], "interface_file": false, "source_file": "WasmSupport.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.UInt32.t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.UInt32.t", "FStar.UInt32.op_Equals_Hat", "FStar.UInt32.__uint_to_t", "WasmSupport.trap", "Prims.unit", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_True" ]
[]
false
true
false
false
false
let check_buffer_size (s: U32.t) : Stack unit (fun _ -> True) (fun _ _ _ -> True) =
if let open U32 in s =^ 0ul then trap "Zero-sized arrays are not supported in C and in WASM either. See WasmSupport.fst"
false
WorkingWithSquashedProofs.fst
WorkingWithSquashedProofs.valid_baz
val valid_baz (a: Type) (x: a) : Lemma (baz a x)
val valid_baz (a: Type) (x: a) : Lemma (baz a x)
let valid_baz (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> // let sf = FStar.Squash.return_squash f in foo_baz x | Prims.Right b -> // let sg = FStar.Squash.return_squash b in bar_baz x in s_baz))
{ "file_name": "examples/misc/WorkingWithSquashedProofs.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 96, "start_col": 0, "start_line": 82 }
(* Copyright 2008-2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module WorkingWithSquashedProofs open FStar.Squash //Mixing squashed an constructive proofs //It's a bit bureaucratic and technical ... I wish this part of F* were simpler //There's a bunch of redundancy between Lemma, squash, GTot, prop, etc. //which is always confusing. //Suppose I have some predicates, it could be that inductive type about //interleaving that you had assume val foo (a:Type) (x:a) : Type assume val bar (a:Type) (x:a) : Type //And let's say I have a way of proving some Lemma based on a proof of this `pred` assume val foo_pf_implies_bar (a:Type) (x:a) (pf:foo a x) : Lemma (bar a x) //Now, if I have `foo` in a refinement, I can still prove `bar, like so //One can use FStar.Squash.bind_squash for that, but it takes a couple of steps //expect_failure is an attribute that tells F* that this next definition will fail [@expect_failure] //but this doesn't quite work because `bind_squash` expects a GTot function but we are giving it a Lemma, which isn't identical let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = let s : squash (foo a x) = () in FStar.Squash.bind_squash #(foo a x) #(bar a x) s (foo_pf_implies_bar a x) //So, to make it work, we need to turn a lemma into a GTot function returning a squash let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x:a) : GTot (squash b) = lem x //Now, I can use FStar.Squash.bind_squash to complete the proof let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = FStar.Squash.bind_squash () (lemma_as_squash (foo_pf_implies_bar a x)) // Another example, this time with disjunctions // Say I have a lemma proving a disjunction assume val foo_or_bar (#a:_) (x:a) : Lemma (foo a x \/ bar a x) assume val baz (a:Type) (x:a) : Type // And let's say I have separate lemmas proving // foo implies baz // and bar impliez baz assume val foo_baz (#a:_) (x:a) : Lemma (requires foo a x) (ensures baz a x) assume val bar_baz (#a:_) (x:a) : Lemma (requires bar a x) (ensures baz a x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "WorkingWithSquashedProofs.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> FStar.Pervasives.Lemma (ensures WorkingWithSquashedProofs.baz a x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Squash.bind_squash", "Prims.l_or", "WorkingWithSquashedProofs.foo", "WorkingWithSquashedProofs.bar", "WorkingWithSquashedProofs.baz", "Prims.sum", "Prims.squash", "WorkingWithSquashedProofs.foo_baz", "WorkingWithSquashedProofs.bar_baz", "WorkingWithSquashedProofs.foo_or_bar", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let valid_baz (a: Type) (x: a) : Lemma (baz a x) =
let s_fb:squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb: (foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb: Prims.sum (foo a x) (bar a x)) -> let s_baz:squash (baz a x) = match c_fb with | Prims.Left f -> foo_baz x | Prims.Right b -> bar_baz x in s_baz))
false
WorkingWithSquashedProofs.fst
WorkingWithSquashedProofs.elim_squash_or
val elim_squash_or (#r #p #q: _) (f: squash (p \/ q)) (left: (p -> GTot r)) (right: (q -> GTot r)) : GTot (squash r)
val elim_squash_or (#r #p #q: _) (f: squash (p \/ q)) (left: (p -> GTot r)) (right: (q -> GTot r)) : GTot (squash r)
let elim_squash_or (#r:_) (#p #q:_) (f:squash (p \/ q)) (left: p -> GTot r) (right: q -> GTot r) : GTot (squash r) = FStar.Squash.bind_squash #_ #r f (fun pq -> FStar.Squash.bind_squash pq (fun c -> match c with | Prims.Left x -> FStar.Squash.return_squash (left x) | Prims.Right x -> FStar.Squash.return_squash (right x)))
{ "file_name": "examples/misc/WorkingWithSquashedProofs.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 133, "start_col": 0, "start_line": 127 }
(* Copyright 2008-2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module WorkingWithSquashedProofs open FStar.Squash //Mixing squashed an constructive proofs //It's a bit bureaucratic and technical ... I wish this part of F* were simpler //There's a bunch of redundancy between Lemma, squash, GTot, prop, etc. //which is always confusing. //Suppose I have some predicates, it could be that inductive type about //interleaving that you had assume val foo (a:Type) (x:a) : Type assume val bar (a:Type) (x:a) : Type //And let's say I have a way of proving some Lemma based on a proof of this `pred` assume val foo_pf_implies_bar (a:Type) (x:a) (pf:foo a x) : Lemma (bar a x) //Now, if I have `foo` in a refinement, I can still prove `bar, like so //One can use FStar.Squash.bind_squash for that, but it takes a couple of steps //expect_failure is an attribute that tells F* that this next definition will fail [@expect_failure] //but this doesn't quite work because `bind_squash` expects a GTot function but we are giving it a Lemma, which isn't identical let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = let s : squash (foo a x) = () in FStar.Squash.bind_squash #(foo a x) #(bar a x) s (foo_pf_implies_bar a x) //So, to make it work, we need to turn a lemma into a GTot function returning a squash let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x:a) : GTot (squash b) = lem x //Now, I can use FStar.Squash.bind_squash to complete the proof let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = FStar.Squash.bind_squash () (lemma_as_squash (foo_pf_implies_bar a x)) // Another example, this time with disjunctions // Say I have a lemma proving a disjunction assume val foo_or_bar (#a:_) (x:a) : Lemma (foo a x \/ bar a x) assume val baz (a:Type) (x:a) : Type // And let's say I have separate lemmas proving // foo implies baz // and bar impliez baz assume val foo_baz (#a:_) (x:a) : Lemma (requires foo a x) (ensures baz a x) assume val bar_baz (#a:_) (x:a) : Lemma (requires bar a x) (ensures baz a x) let valid_baz (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> // let sf = FStar.Squash.return_squash f in foo_baz x | Prims.Right b -> // let sg = FStar.Squash.return_squash b in bar_baz x in s_baz)) // And here's a variant where the lemmas I want to call // expect proof terms of foo or bar assume val c_foo_baz (#a:_) (x:a) (_:foo a x) : Lemma (ensures baz a x) assume val c_bar_baz (#a:_) (x:a) (_:bar a x) : Lemma (ensures baz a x) let valid_baz_alt (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> c_foo_baz x f | Prims.Right b -> c_bar_baz x b in s_baz)) //We can wrap that up into a combinator like so
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "WorkingWithSquashedProofs.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Prims.squash (p \/ q) -> left: (_: p -> Prims.GTot r) -> right: (_: q -> Prims.GTot r) -> Prims.GTot (Prims.squash r)
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.logical", "Prims.squash", "Prims.l_or", "FStar.Squash.bind_squash", "Prims.sum", "FStar.Squash.return_squash" ]
[]
false
false
true
false
false
let elim_squash_or (#r #p #q: _) (f: squash (p \/ q)) (left: (p -> GTot r)) (right: (q -> GTot r)) : GTot (squash r) =
FStar.Squash.bind_squash #_ #r f (fun pq -> FStar.Squash.bind_squash pq (function | Prims.Left x -> FStar.Squash.return_squash (left x) | Prims.Right x -> FStar.Squash.return_squash (right x)))
false
WorkingWithSquashedProofs.fst
WorkingWithSquashedProofs.foo_implies_bar
val foo_implies_bar (a: Type) (x: a{foo a x}) : Lemma (bar a x)
val foo_implies_bar (a: Type) (x: a{foo a x}) : Lemma (bar a x)
let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = FStar.Squash.bind_squash () (lemma_as_squash (foo_pf_implies_bar a x))
{ "file_name": "examples/misc/WorkingWithSquashedProofs.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 74, "end_line": 56, "start_col": 0, "start_line": 54 }
(* Copyright 2008-2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module WorkingWithSquashedProofs open FStar.Squash //Mixing squashed an constructive proofs //It's a bit bureaucratic and technical ... I wish this part of F* were simpler //There's a bunch of redundancy between Lemma, squash, GTot, prop, etc. //which is always confusing. //Suppose I have some predicates, it could be that inductive type about //interleaving that you had assume val foo (a:Type) (x:a) : Type assume val bar (a:Type) (x:a) : Type //And let's say I have a way of proving some Lemma based on a proof of this `pred` assume val foo_pf_implies_bar (a:Type) (x:a) (pf:foo a x) : Lemma (bar a x) //Now, if I have `foo` in a refinement, I can still prove `bar, like so //One can use FStar.Squash.bind_squash for that, but it takes a couple of steps //expect_failure is an attribute that tells F* that this next definition will fail [@expect_failure] //but this doesn't quite work because `bind_squash` expects a GTot function but we are giving it a Lemma, which isn't identical let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = let s : squash (foo a x) = () in FStar.Squash.bind_squash #(foo a x) #(bar a x) s (foo_pf_implies_bar a x) //So, to make it work, we need to turn a lemma into a GTot function returning a squash let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x:a) : GTot (squash b) = lem x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "WorkingWithSquashedProofs.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a{WorkingWithSquashedProofs.foo a x} -> FStar.Pervasives.Lemma (ensures WorkingWithSquashedProofs.bar a x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "WorkingWithSquashedProofs.foo", "FStar.Squash.bind_squash", "WorkingWithSquashedProofs.bar", "WorkingWithSquashedProofs.lemma_as_squash", "WorkingWithSquashedProofs.foo_pf_implies_bar", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let foo_implies_bar (a: Type) (x: a{foo a x}) : Lemma (bar a x) =
FStar.Squash.bind_squash () (lemma_as_squash (foo_pf_implies_bar a x))
false
WorkingWithSquashedProofs.fst
WorkingWithSquashedProofs.lemma_as_squash
val lemma_as_squash (#a #b: _) ($lem: (a -> Lemma b)) (x: a) : GTot (squash b)
val lemma_as_squash (#a #b: _) ($lem: (a -> Lemma b)) (x: a) : GTot (squash b)
let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x:a) : GTot (squash b) = lem x
{ "file_name": "examples/misc/WorkingWithSquashedProofs.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 51, "start_col": 0, "start_line": 49 }
(* Copyright 2008-2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module WorkingWithSquashedProofs open FStar.Squash //Mixing squashed an constructive proofs //It's a bit bureaucratic and technical ... I wish this part of F* were simpler //There's a bunch of redundancy between Lemma, squash, GTot, prop, etc. //which is always confusing. //Suppose I have some predicates, it could be that inductive type about //interleaving that you had assume val foo (a:Type) (x:a) : Type assume val bar (a:Type) (x:a) : Type //And let's say I have a way of proving some Lemma based on a proof of this `pred` assume val foo_pf_implies_bar (a:Type) (x:a) (pf:foo a x) : Lemma (bar a x) //Now, if I have `foo` in a refinement, I can still prove `bar, like so //One can use FStar.Squash.bind_squash for that, but it takes a couple of steps //expect_failure is an attribute that tells F* that this next definition will fail [@expect_failure] //but this doesn't quite work because `bind_squash` expects a GTot function but we are giving it a Lemma, which isn't identical let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = let s : squash (foo a x) = () in FStar.Squash.bind_squash #(foo a x) #(bar a x) s (foo_pf_implies_bar a x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "WorkingWithSquashedProofs.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (_: a -> FStar.Pervasives.Lemma (ensures b)) -> x: a -> Prims.GTot (Prims.squash b)
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x: a) : GTot (squash b) =
lem x
false
GT.fst
GT.m
val m (a: Type u#aa) (i: idx) : Type u#aa
val m (a: Type u#aa) (i: idx) : Type u#aa
let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a)
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 18, "start_col": 0, "start_line": 14 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> i: GT.idx -> Type
Prims.Tot
[ "total" ]
[]
[ "GT.idx", "Prims.unit", "FStar.Universe.raise_t" ]
[]
false
false
false
true
true
let m (a: Type u#aa) (i: idx) : Type u#aa =
match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a)
false
WorkingWithSquashedProofs.fst
WorkingWithSquashedProofs.valid_baz_alt
val valid_baz_alt (a: Type) (x: a) : Lemma (baz a x)
val valid_baz_alt (a: Type) (x: a) : Lemma (baz a x)
let valid_baz_alt (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> c_foo_baz x f | Prims.Right b -> c_bar_baz x b in s_baz))
{ "file_name": "examples/misc/WorkingWithSquashedProofs.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 123, "start_col": 0, "start_line": 111 }
(* Copyright 2008-2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module WorkingWithSquashedProofs open FStar.Squash //Mixing squashed an constructive proofs //It's a bit bureaucratic and technical ... I wish this part of F* were simpler //There's a bunch of redundancy between Lemma, squash, GTot, prop, etc. //which is always confusing. //Suppose I have some predicates, it could be that inductive type about //interleaving that you had assume val foo (a:Type) (x:a) : Type assume val bar (a:Type) (x:a) : Type //And let's say I have a way of proving some Lemma based on a proof of this `pred` assume val foo_pf_implies_bar (a:Type) (x:a) (pf:foo a x) : Lemma (bar a x) //Now, if I have `foo` in a refinement, I can still prove `bar, like so //One can use FStar.Squash.bind_squash for that, but it takes a couple of steps //expect_failure is an attribute that tells F* that this next definition will fail [@expect_failure] //but this doesn't quite work because `bind_squash` expects a GTot function but we are giving it a Lemma, which isn't identical let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = let s : squash (foo a x) = () in FStar.Squash.bind_squash #(foo a x) #(bar a x) s (foo_pf_implies_bar a x) //So, to make it work, we need to turn a lemma into a GTot function returning a squash let lemma_as_squash #a #b ($lem: (a -> Lemma b)) (x:a) : GTot (squash b) = lem x //Now, I can use FStar.Squash.bind_squash to complete the proof let foo_implies_bar (a:Type) (x:a{foo a x}) : Lemma (bar a x) = FStar.Squash.bind_squash () (lemma_as_squash (foo_pf_implies_bar a x)) // Another example, this time with disjunctions // Say I have a lemma proving a disjunction assume val foo_or_bar (#a:_) (x:a) : Lemma (foo a x \/ bar a x) assume val baz (a:Type) (x:a) : Type // And let's say I have separate lemmas proving // foo implies baz // and bar impliez baz assume val foo_baz (#a:_) (x:a) : Lemma (requires foo a x) (ensures baz a x) assume val bar_baz (#a:_) (x:a) : Lemma (requires bar a x) (ensures baz a x) let valid_baz (a:Type) (x:a) : Lemma (baz a x) = let s_fb : squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb:(foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb:Prims.sum (foo a x) (bar a x)) -> let s_baz : squash (baz a x) = match c_fb with | Prims.Left f -> // let sf = FStar.Squash.return_squash f in foo_baz x | Prims.Right b -> // let sg = FStar.Squash.return_squash b in bar_baz x in s_baz)) // And here's a variant where the lemmas I want to call // expect proof terms of foo or bar assume val c_foo_baz (#a:_) (x:a) (_:foo a x) : Lemma (ensures baz a x) assume val c_bar_baz (#a:_) (x:a) (_:bar a x) : Lemma (ensures baz a x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "WorkingWithSquashedProofs.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> FStar.Pervasives.Lemma (ensures WorkingWithSquashedProofs.baz a x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Squash.bind_squash", "Prims.l_or", "WorkingWithSquashedProofs.foo", "WorkingWithSquashedProofs.bar", "WorkingWithSquashedProofs.baz", "Prims.sum", "Prims.squash", "WorkingWithSquashedProofs.c_foo_baz", "WorkingWithSquashedProofs.c_bar_baz", "WorkingWithSquashedProofs.foo_or_bar", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let valid_baz_alt (a: Type) (x: a) : Lemma (baz a x) =
let s_fb:squash (foo a x \/ bar a x) = foo_or_bar x in FStar.Squash.bind_squash s_fb (fun (fb: (foo a x \/ bar a x)) -> FStar.Squash.bind_squash fb (fun (c_fb: Prims.sum (foo a x) (bar a x)) -> let s_baz:squash (baz a x) = match c_fb with | Prims.Left f -> c_foo_baz x f | Prims.Right b -> c_bar_baz x b in s_baz))
false
GT.fst
GT.r_map
val r_map (#i #a #b: _) (f: (a -> m b i)) (xs: list a) : m (list b) i
val r_map (#i #a #b: _) (f: (a -> m b i)) (xs: list a) : m (list b) i
let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _))
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 48, "start_col": 0, "start_line": 42 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> GT.m b i) -> xs: Prims.list a -> GT.m (Prims.list b) i
Prims.Tot
[ "total" ]
[]
[ "GT.idx", "GT.m", "Prims.list", "GT.return", "Prims.Nil", "GT.bind", "GT.r_map", "Prims.Cons" ]
[ "recursion" ]
false
false
false
false
false
let rec r_map #i #a #b (f: (a -> m b i)) (xs: list a) : m (list b) i =
match xs with | [] -> return _ [] _ | x :: xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y :: ys) _))
false
GT.fst
GT.bind
val bind (a b: Type) (i: idx) (c: m a i) (f: (a -> m b i)) : m b i
val bind (a b: Type) (i: idx) (c: m a i) (f: (a -> m b i)) : m b i
let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 39, "start_col": 0, "start_line": 35 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ())
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: Type -> i: GT.idx -> c: GT.m a i -> f: (_: a -> GT.m b i) -> GT.m b i
Prims.Tot
[ "total" ]
[]
[ "GT.idx", "GT.m", "GT.t_bind", "GT.coerce", "GT.D", "GT.d_bind", "GT.g_bind" ]
[]
false
false
false
false
false
let bind (a b: Type) (i: idx) (c: m a i) (f: (a -> m b i)) : m b i =
match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) | G -> g_bind #a #b c f
false
GT.fst
GT.coerce
val coerce (#a #b: _) (x: a{a == b}) : b
val coerce (#a #b: _) (x: a{a == b}) : b
let coerce #a #b (x:a{a == b}) : b = x
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 12, "start_col": 0, "start_line": 12 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a{a == b} -> b
Prims.Tot
[ "total" ]
[]
[ "Prims.eq2" ]
[]
false
false
false
false
false
let coerce #a #b (x: a{a == b}) : b =
x
false
GT.fst
GT.appn
val appn (#a #i: _) (n: nat) (f: (a -> GTD a i)) (x: a) : GTD a i
val appn (#a #i: _) (n: nat) (f: (a -> GTD a i)) (x: a) : GTD a i
let rec appn #a #i (n:nat) (f : a -> GTD a i) (x : a) : GTD a i = match n with | 0 -> x | _ -> begin appn (n-1) f (f x) end
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 103, "start_col": 0, "start_line": 98 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) () let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f let if_then_else (a:Type) (i:idx) (f : m a i) (g : m a i) (b : bool) : Type = m a i // GM: Would be nice to not have to use all explicit args everywhere, // and to get better errors especially when args are out of order, // e.g. the [idx] in [return] needs to come after [x], otherwise // we get an assertion failure trying to prove [forall (a: Type). idx == a]. reifiable reflectable effect { GTD (a:Type) ([@@@ effect_param] _:idx) with {repr = m; return; bind; subcomp; if_then_else} } let lift_pure_gtd (a:Type) (wp : pure_wp a) (i : idx) (f : unit -> PURE a wp) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) = //f // GM: Surprised that this works actually... I expected that I would need to // case analyze [i]. // GM: ok not anymore FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a)) sub_effect PURE ~> GTD = lift_pure_gtd let rec map #a #b #i (f : a -> GTD b i) (xs : list a) : GTD (list b) i = match xs with | [] -> [] | x::xs -> (f x)::(map f xs) let app #a #b #i (f : a -> GTD b i) (x : a) : GTD b i = f x // todo: use map/app from tot context and prove that it does what it's meant to do open FStar.Tactics.V2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> f: (_: a -> GT.GTD a) -> x: a -> GT.GTD a
GT.GTD
[]
[]
[ "GT.idx", "Prims.nat", "Prims.int", "GT.appn", "Prims.op_Subtraction" ]
[ "recursion" ]
false
true
false
false
false
let rec appn #a #i (n: nat) (f: (a -> GTD a i)) (x: a) : GTD a i =
match n with | 0 -> x | _ -> appn (n - 1) f (f x)
false
GT.fst
GT.map
val map (#a #b #i: _) (f: (a -> GTD b i)) (xs: list a) : GTD (list b) i
val map (#a #b #i: _) (f: (a -> GTD b i)) (xs: list a) : GTD (list b) i
let rec map #a #b #i (f : a -> GTD b i) (xs : list a) : GTD (list b) i = match xs with | [] -> [] | x::xs -> (f x)::(map f xs)
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 90, "start_col": 0, "start_line": 87 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) () let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f let if_then_else (a:Type) (i:idx) (f : m a i) (g : m a i) (b : bool) : Type = m a i // GM: Would be nice to not have to use all explicit args everywhere, // and to get better errors especially when args are out of order, // e.g. the [idx] in [return] needs to come after [x], otherwise // we get an assertion failure trying to prove [forall (a: Type). idx == a]. reifiable reflectable effect { GTD (a:Type) ([@@@ effect_param] _:idx) with {repr = m; return; bind; subcomp; if_then_else} } let lift_pure_gtd (a:Type) (wp : pure_wp a) (i : idx) (f : unit -> PURE a wp) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) = //f // GM: Surprised that this works actually... I expected that I would need to // case analyze [i]. // GM: ok not anymore FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a)) sub_effect PURE ~> GTD = lift_pure_gtd
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> GT.GTD b) -> xs: Prims.list a -> GT.GTD (Prims.list b)
GT.GTD
[]
[]
[ "GT.idx", "Prims.list", "Prims.Nil", "Prims.Cons", "GT.map" ]
[ "recursion" ]
false
true
false
false
false
let rec map #a #b #i (f: (a -> GTD b i)) (xs: list a) : GTD (list b) i =
match xs with | [] -> [] | x :: xs -> (f x) :: (map f xs)
false
GT.fst
GT.lift_pure_gtd
val lift_pure_gtd (a: Type) (wp: pure_wp a) (i: idx) (f: (unit -> PURE a wp)) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True))
val lift_pure_gtd (a: Type) (wp: pure_wp a) (i: idx) (f: (unit -> PURE a wp)) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True))
let lift_pure_gtd (a:Type) (wp : pure_wp a) (i : idx) (f : unit -> PURE a wp) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) = //f // GM: Surprised that this works actually... I expected that I would need to // case analyze [i]. // GM: ok not anymore FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a))
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 83, "start_col": 0, "start_line": 70 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) () let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f let if_then_else (a:Type) (i:idx) (f : m a i) (g : m a i) (b : bool) : Type = m a i // GM: Would be nice to not have to use all explicit args everywhere, // and to get better errors especially when args are out of order, // e.g. the [idx] in [return] needs to come after [x], otherwise // we get an assertion failure trying to prove [forall (a: Type). idx == a]. reifiable reflectable effect { GTD (a:Type) ([@@@ effect_param] _:idx) with {repr = m; return; bind; subcomp; if_then_else} }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> wp: Prims.pure_wp a -> i: GT.idx -> f: (_: Prims.unit -> Prims.PURE a) -> Prims.Pure (GT.m a i)
Prims.Pure
[]
[]
[ "Prims.pure_wp", "GT.idx", "Prims.unit", "GT.coerce", "FStar.Universe.raise_t", "GT.m", "FStar.Universe.raise_val", "FStar.Monotonic.Pure.elim_pure_wp_monotonicity", "Prims.l_True" ]
[]
false
false
false
false
false
let lift_pure_gtd (a: Type) (wp: pure_wp a) (i: idx) (f: (unit -> PURE a wp)) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) =
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a))
false
GT.fst
GT.labs
val labs (#i: _) (n: int) : GTD nat i
val labs (#i: _) (n: int) : GTD nat i
let labs #i (n:int) : GTD nat i = if n < 0 then -n else n
{ "file_name": "examples/layeredeffects/GT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 8, "end_line": 118, "start_col": 0, "start_line": 115 }
module GT open FStar.Tactics.V2 open FStar.Universe type idx = | T | G | D // GM: Force a type equality by SMT let coerce #a #b (x:a{a == b}) : b = x let m (a:Type u#aa) (i:idx) : Type u#aa = match i with | T -> unit -> Tot a | G -> unit -> GTot a | D -> raise_t (unit -> Dv a) let t_return #a (x:a) : m a T = (fun () -> x) let g_return #a (x:a) : m a G = (fun () -> x) let d_return #a (x:a) : m a D = raise_val (fun () -> x) let return (a:Type) (x:a) (i:idx) : m a i = match i with | T -> t_return x | G -> g_return x | D -> d_return x let t_bind #a #b (c : m a T) (f : a -> m b T) : m b T = fun () -> f (c ()) () let g_bind #a #b (c : m a G) (f : a -> m b G) : m b G = fun () -> f (c ()) () let d_bind #a #b (c : m a D) (f : a -> m b D) : m b D = raise_val (fun () -> downgrade_val (f (downgrade_val c ())) ()) let bind (a b : Type) (i:idx) (c : m a i) (f : a -> m b i) : m b i = match i with | T -> t_bind #a #b c f | D -> coerce (d_bind #a #b c f) // GM: wow... still needs a coerce, how can that be? | G -> g_bind #a #b c f // Already somewhat usable let rec r_map #i #a #b (f : a -> m b i) (xs : list a) : m (list b) i = match xs with | [] -> return _ [] _ | x::xs -> bind _ _ _ (f x) (fun y -> bind _ _ _ (r_map f xs) (fun ys -> return _ (y::ys) _)) let t1_t () : Tot (list int) = r_map #T (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_g () : GTot (list int) = r_map #G (fun x -> fun () -> x + 1) [1;2;3;4] () let t1_d () : Dv (list int) = downgrade_val (r_map #D (fun x -> raise_val (fun () -> x + 1)) [1;2;3;4]) () let subcomp (a:Type) (i:idx) (f : m a i) : m a i = f let if_then_else (a:Type) (i:idx) (f : m a i) (g : m a i) (b : bool) : Type = m a i // GM: Would be nice to not have to use all explicit args everywhere, // and to get better errors especially when args are out of order, // e.g. the [idx] in [return] needs to come after [x], otherwise // we get an assertion failure trying to prove [forall (a: Type). idx == a]. reifiable reflectable effect { GTD (a:Type) ([@@@ effect_param] _:idx) with {repr = m; return; bind; subcomp; if_then_else} } let lift_pure_gtd (a:Type) (wp : pure_wp a) (i : idx) (f : unit -> PURE a wp) : Pure (m a i) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) = //f // GM: Surprised that this works actually... I expected that I would need to // case analyze [i]. // GM: ok not anymore FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; match i with | T -> f | G -> f | D -> coerce (raise_val (fun () -> f () <: Dv a)) sub_effect PURE ~> GTD = lift_pure_gtd let rec map #a #b #i (f : a -> GTD b i) (xs : list a) : GTD (list b) i = match xs with | [] -> [] | x::xs -> (f x)::(map f xs) let app #a #b #i (f : a -> GTD b i) (x : a) : GTD b i = f x // todo: use map/app from tot context and prove that it does what it's meant to do open FStar.Tactics.V2 let rec appn #a #i (n:nat) (f : a -> GTD a i) (x : a) : GTD a i = match n with | 0 -> x | _ -> begin appn (n-1) f (f x) end [@@expect_failure] let test #a #i (n:int) : GTD nat i = let r = app abs n in r let labs0 #i (n:int) : GTD int i = if n < 0 then -n else n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked" ], "interface_file": false, "source_file": "GT.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.int -> GT.GTD Prims.nat
GT.GTD
[]
[]
[ "GT.idx", "Prims.int", "Prims.op_LessThan", "Prims.op_Minus", "Prims.bool", "Prims.nat" ]
[]
false
true
false
false
false
let labs #i (n: int) : GTD nat i =
if n < 0 then - n else n
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_dsum_payload'
val gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k))
val gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k))
let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) = fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) // dummy in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res } ))
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 131, "end_line": 1839, "start_col": 0, "start_line": 1819 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl' let gaccessor_clens_sum_payload (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_injective t p pc k x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_clens_sum_payload_no_lookahead t p pc k x)); gaccessor_prop_equiv (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) (gaccessor_clens_sum_payload' t p pc k); gaccessor_clens_sum_payload' t p pc k inline_for_extraction let accessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_sum t p pc) h input pos /\ (clens_sum_payload t k).clens_cond (contents (parse_sum t p pc) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_clens_sum_payload t p pc k) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_sum t p pc) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_clens_sum_payload t p pc k) input pos; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq'' t p pc large; valid_facts p h input pos in j input pos #pop-options inline_for_extraction let accessor_clens_sum_payload (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_payload t p pc k)) = fun #rrel #rel -> accessor_clens_sum_payload' t j pc k #rrel #rel let clens_sum_cases_payload (s: sum) (k: sum_key s) : Tot (clens (sum_cases s k) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_cases s k) -> True); clens_get = (fun (x: sum_cases s k) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (True)) (ensures (fun _ -> True))); } let gaccessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor (parse_sum_cases' t pc k) (dsnd (pc k)) (clens_sum_cases_payload t k)) = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); gaccessor_ext (gaccessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let accessor_clens_sum_cases_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (accessor (gaccessor_clens_sum_cases_payload t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k; synth_sum_case_inverse t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) () in accessor_ext (accessor_synth (dsnd (pc k)) (synth_sum_case t k) (synth_sum_case_recip t k) ()) (clens_sum_cases_payload t k) () inline_for_extraction let validate_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = validator (parse_dsum_cases' s f g x) let validate_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : validate_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let validate_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (validate_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (validate_dsum_cases_t s f g x))) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: validate_dsum_cases_t s f g x) input len else (iff () <: validate_dsum_cases_t s f g x) input len inline_for_extraction let validate_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (validate_dsum_cases_eq s f g x)) = validate_dsum_cases_if' s f g x inline_for_extraction let validate_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = [@inline_let] let _ = synth_dsum_case_injective s x in match x with | Known x' -> validate_synth (f' x') (synth_dsum_case s (Known x')) () <: validator (parse_dsum_cases' s f g x) | Unknown x' -> validate_synth g' (synth_dsum_case s (Unknown x')) () <: validator (parse_dsum_cases' s f g x) inline_for_extraction let validate_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validate_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> validate_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> validate_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> validate_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let validate_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (validator (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : validator g) (destr: dep_enum_destr _ (fun k -> validate_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (validator (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input (uint64_to_uint32 pos); valid_facts (parse_dsum_cases s f g x) h input (uint64_to_uint32 pos); parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input (uint64_to_uint32 pos)) in validate_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 40" inline_for_extraction let validate_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: validator p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (validator (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: validator g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (validate_dsum_cases_t t f g)) : Tot (validator (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let pos_after_tag = v input pos in if is_error pos_after_tag then pos_after_tag else let tg = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input (uint64_to_uint32 pos_after_tag) in destr (validate_dsum_cases_eq t f g) (validate_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options #reset-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" let valid_dsum_intro_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) )))) (ensures ( let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) let valid_dsum_intro_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ valid g h input (get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos) ))) (ensures ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload; valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos) #reset-options inline_for_extraction let finalize_dsum_case_known (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (destr: enum_repr_of_key'_t (dsum_enum t)) (k: dsum_known_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (f k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (dsum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )) = let pos1 = write_enum_key w (dsum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_enum_key p (dsum_enum t)) h input pos; valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let sq = bytes_of_slice_from h input pos in parse_enum_key_eq p (dsum_enum t) sq; parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_known h t p f g input pos in () inline_for_extraction let finalize_dsum_case_unknown (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (r: unknown_enum_repr (dsum_enum t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length s r in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid g h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length s r in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_dsum t p f g) h' input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )) = let pos1 = w r input pos in let h = HST.get () in [@inline_let] let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; valid_facts p h input pos; let sq = bytes_of_slice_from h input pos in parse_maybe_enum_key_eq p (dsum_enum t) sq; valid_dsum_intro_unknown h t p f g input pos in () let valid_dsum_elim_tag (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ contents (parse_maybe_enum_key p (dsum_enum t)) h input pos == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let _ = parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_dsum t p f g) h input pos in let _ = valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos in () inline_for_extraction let read_dsum_tag (t: dsum) (#kt: parser_kind) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader p) (destr: maybe_enum_destr_t (maybe_enum_key (dsum_enum t)) (dsum_enum t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (dsum_key t) (requires (fun h -> valid (parse_dsum t p f g) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_dsum_elim_tag h t p f g input pos in read_maybe_enum_key p32 (dsum_enum t) destr input pos #push-options "--z3rlimit 32" let valid_dsum_elim_known (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Known? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Known? k' /\ ( let Known k = k' in valid (dsnd (f k)) h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Known k) (contents (dsnd (f k)) h input pos_payload)) (get_valid_pos (dsnd (f k)) h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Known k = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts (dsnd (f k)) h input pos_payload #pop-options let valid_dsum_elim_unknown (h: HS.mem) (t: dsum) (#kt: parser_kind) (p: parser kt (dsum_repr_type t)) (f: ((x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_dsum t p f g) h input pos /\ Unknown? (dsum_tag_of_data t (contents (parse_dsum t p f g) h input pos)) )) (ensures ( valid (parse_maybe_enum_key p (dsum_enum t)) h input pos /\ ( let k' = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in Unknown? k' /\ ( let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid g h input pos_payload /\ valid_content_pos (parse_dsum t p f g) h input pos (synth_dsum_case t (Unknown r) (contents g h input pos_payload)) (get_valid_pos g h input pos_payload) )))) = valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let Unknown r = contents (parse_maybe_enum_key p (dsum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_maybe_enum_key p (dsum_enum t)) h input pos in valid_facts g h input pos_payload inline_for_extraction let jump_dsum_cases_t (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot Type = jumper (parse_dsum_cases' s f g x) let jump_dsum_cases_eq (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (v1 v2 : jump_dsum_cases_t s f g x) : GTot Type0 = True inline_for_extraction let jump_dsum_cases_if' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) (cond: bool) (ift: (cond_true cond -> Tot (jump_dsum_cases_t s f g x))) (iff: (cond_false cond -> Tot (jump_dsum_cases_t s f g x))) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input len -> if cond then (ift () <: jump_dsum_cases_t s f g x) input len else (iff () <: jump_dsum_cases_t s f g x) input len inline_for_extraction let jump_dsum_cases_if (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (#k: parser_kind) (g: parser k (dsum_type_of_unknown_tag s)) (x: dsum_key s) : Tot (if_combinator _ (jump_dsum_cases_eq s f g x)) = jump_dsum_cases_if' s f g x inline_for_extraction let jump_dsum_cases' (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = synth_dsum_case_injective s x; match x with | Known x' -> jump_synth (f' x') (synth_dsum_case s (Known x')) () <: jumper (parse_dsum_cases' s f g x) | Unknown x' -> jump_synth g' (synth_dsum_case s (Unknown x')) () <: jumper (parse_dsum_cases' s f g x) inline_for_extraction let jump_dsum_cases'_destr (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jump_dsum_cases_t s f g x) = fun #rrel #rel input pos -> match x with | Known k -> destr _ (fun k -> jump_dsum_cases_if s f g (Known k)) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> jump_dsum_cases' s f f' g' (Known k)) k input pos | Unknown r -> jump_dsum_cases' s f f' g' (Unknown r) input pos inline_for_extraction let jump_dsum_cases (s: dsum) (f: (x: dsum_known_key s) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag s x))) (f' : (x: dsum_known_key s) -> Tot (jumper (dsnd (f x)))) (#k: parser_kind) (#g: parser k (dsum_type_of_unknown_tag s)) (g' : jumper g) (destr: dep_enum_destr _ (fun k -> jump_dsum_cases_t s f g (Known k))) (x: dsum_key s) : Tot (jumper (parse_dsum_cases s f g x)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_dsum_cases' s f g x) h input pos; valid_facts (parse_dsum_cases s f g x) h input pos; parse_dsum_cases_eq' s f g x (bytes_of_slice_from h input pos) in jump_dsum_cases'_destr s f f' g' destr x input pos #push-options "--z3rlimit 16" inline_for_extraction let jump_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (jumper (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: jumper g) (destr: dep_maybe_enum_destr_t (dsum_enum t) (jump_dsum_cases_t t f g)) : Tot (jumper (parse_dsum t p f g)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_dsum_eq' t p f g (bytes_of_slice_from h input pos) in [@inline_let] let _ = valid_facts (parse_dsum t p f g) h input pos in [@inline_let] let _ = valid_facts p h input pos in let pos_after_tag = v input pos in let tg = p32 input pos in [@inline_let] let _ = valid_facts (parse_dsum_cases' t f g (maybe_enum_key_of_repr (dsum_enum t) tg)) h input pos_after_tag in destr (jump_dsum_cases_eq t f g) (jump_dsum_cases_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_dsum_cases' t f f32 g32) tg input pos_after_tag #pop-options inline_for_extraction let read_dsum_cases' (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #rrel #rel input pos -> [@inline_let] let _ = synth_dsum_case_injective t x in match x with | Known x' -> read_synth' (dsnd (f x')) (synth_dsum_case t (Known x')) (f32 x') () input pos | Unknown x' -> read_synth' g (synth_dsum_case t (Unknown x')) g32 () input pos inline_for_extraction let read_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot Type = leaf_reader (parse_dsum_cases' t f g (Known k)) let read_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) (x y : read_dsum_cases_t t f g k) : GTot Type0 = True inline_for_extraction let read_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (k: dsum_known_key t) : Tot (if_combinator _ (read_dsum_cases_t_eq t f g k)) = fun cond (sv_true: cond_true cond -> Tot (read_dsum_cases_t t f g k)) (sv_false: cond_false cond -> Tot (read_dsum_cases_t t f g k)) #_ #_ input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let read_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) (x: dsum_key t) : Tot (leaf_reader (parse_dsum_cases' t f g x)) = fun #_ #_ input pos -> match x with | Known k -> destr _ (read_dsum_cases_t_if t f g) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> read_dsum_cases' t f f32 g g32 (Known k)) k input pos | Unknown r -> read_dsum_cases' t f f32 g g32 (Unknown r) input pos #push-options "--z3rlimit 16" inline_for_extraction let read_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (p32: leaf_reader (parse_maybe_enum_key p (dsum_enum t))) (j: jumper p) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (f32: (x: dsum_known_key t) -> Tot (leaf_reader (dsnd (f x)))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (g32: leaf_reader g) (destr: dep_enum_destr _ (read_dsum_cases_t t f g)) : Tot (leaf_reader (parse_dsum t p f g)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_dsum t p f g) h input pos; parse_dsum_eq_ t p f g (bytes_of_slice_from h input pos); valid_facts (parse_maybe_enum_key p (dsum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_maybe_enum_key j (dsum_enum t) input pos in valid_facts (parse_dsum_cases' t f g k) h input pos' ; read_dsum_cases t f f32 g g32 destr k input pos' #pop-options inline_for_extraction let serialize32_dsum_type_of_tag (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_type_of_tag t f sf g sg tg)) = match tg with | Known x' -> serialize32_ext (dsnd (f x')) (sf x') (sf32 x') (parse_dsum_type_of_tag t f g tg) () | Unknown x' -> serialize32_ext g sg sg32 (parse_dsum_type_of_tag t f g tg) () inline_for_extraction let serialize32_dsum_cases_aux (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = [@inline_let] let _ = synth_dsum_case_injective t tg in [@inline_let] let _ = synth_dsum_case_inverse t tg in serialize32_synth (serialize32_dsum_type_of_tag t f sf sf32 sg32 tg) (synth_dsum_case t tg) (synth_dsum_case_recip t tg) (fun x -> synth_dsum_case_recip t tg x) () inline_for_extraction let serialize32_dsum_cases_t (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot Type = serializer32 (serialize_dsum_cases t f sf g sg (Known k)) let serialize32_dsum_cases_t_eq (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) (x y: serialize32_dsum_cases_t t f sf g sg k) : GTot Type0 = True inline_for_extraction let serialize32_dsum_cases_t_if (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (#k': parser_kind) (g: parser k' (dsum_type_of_unknown_tag t)) (sg: serializer g) (k: dsum_known_key t) : Tot (if_combinator _ (serialize32_dsum_cases_t_eq t f sf g sg k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) (sv_false: (cond_false cond -> Tot (serialize32_dsum_cases_t t f sf g sg k))) x #rrel #rel output pos -> if cond then (sv_true () x output pos) else (sv_false () x output pos) inline_for_extraction let serialize32_dsum_cases (t: dsum) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) (tg: dsum_key t) : Tot (serializer32 (serialize_dsum_cases t f sf g sg tg)) = fun x #rrel #rel output pos -> match tg with | Known k -> destr _ (serialize32_dsum_cases_t_if t f sf g sg) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (fun k -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Known k)) k x output pos | Unknown r -> serialize32_dsum_cases_aux t f sf sf32 sg32 (Unknown r) x output pos inline_for_extraction let serialize32_dsum (#kt: parser_kind) (t: dsum) (#p: parser kt (dsum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_maybe_enum_key _ s (dsum_enum t))) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (sf: (x: dsum_known_key t) -> Tot (serializer (dsnd (f x)))) (sf32: (x: dsum_known_key t) -> Tot (serializer32 (sf x))) (#k': parser_kind) (#g: parser k' (dsum_type_of_unknown_tag t)) (#sg: serializer g) (sg32: serializer32 sg) (destr: dep_enum_destr _ (serialize32_dsum_cases_t t f sf g sg)) : Tot (serializer32 (serialize_dsum t s f sf g sg)) = fun x #_ #_ output pos -> [@inline_let] let _ = serialize_dsum_eq' t s f sf g sg x in let tg = dsum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_dsum_cases t f sf sf32 sg32 destr tg) tg x output pos let clens_dsum_tag (s: dsum) : Tot (clens (dsum_type s) (dsum_key s)) = { clens_cond = (fun _ -> True); clens_get = dsum_tag_of_data s; } let gaccessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (gaccessor (parse_dsum t p f g) (parse_maybe_enum_key p (dsum_enum t)) (clens_dsum_tag t)) = gaccessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) inline_for_extraction let accessor_dsum_tag (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t) -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) : Tot (accessor (gaccessor_dsum_tag t p f g)) = accessor_tagged_union_tag (parse_maybe_enum_key p (dsum_enum t)) (dsum_tag_of_data t) (parse_dsum_cases t f g) let clens_dsum_payload (s: dsum) (k: dsum_key s) : Tot (clens (dsum_type s) (dsum_type_of_tag s k)) = { clens_cond = (fun (x: dsum_type s) -> dsum_tag_of_data s x == k); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s k x <: Ghost (dsum_type_of_tag s k) (requires (dsum_tag_of_data s x == k)) (ensures (fun _ -> True))); } let clens_dsum_unknown_payload (s: dsum) : Tot (clens (dsum_type s) (dsum_type_of_unknown_tag s)) = { clens_cond = (fun (x: dsum_type s) -> Unknown? (dsum_tag_of_data s x)); clens_get = (fun (x: dsum_type s) -> synth_dsum_case_recip s (dsum_tag_of_data s x) x <: Ghost (dsum_type_of_unknown_tag s) (requires (Unknown? (dsum_tag_of_data s x))) (ensures (fun _ -> True))); } #push-options "--z3rlimit 16"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.dsum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.dsum_repr_type t) -> f: (x: LowParse.Spec.Sum.dsum_known_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.dsum_type_of_known_tag t x))) -> g: LowParse.Spec.Base.parser ku (LowParse.Spec.Sum.dsum_type_of_unknown_tag t) -> k: LowParse.Spec.Sum.dsum_key t -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.Sum.parse_dsum t p f g) (LowParse.Spec.Sum.parse_dsum_type_of_tag' t f g k) (LowParse.Low.Sum.clens_dsum_payload t k)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Sum.dsum", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.dsum_repr_type", "LowParse.Spec.Sum.dsum_known_key", "Prims.dtuple2", "LowParse.Spec.Sum.dsum_type_of_known_tag", "LowParse.Spec.Sum.dsum_type_of_unknown_tag", "LowParse.Spec.Sum.dsum_key", "LowParse.Bytes.bytes", "Prims.nat", "LowParse.Low.Base.Spec.gaccessor_post'", "LowParse.Spec.Sum.parse_dsum_kind", "LowParse.Spec.Sum.dsum_type", "LowParse.Spec.Sum.parse_dsum", "LowParse.Spec.Sum.parse_dsum_cases_kind", "LowParse.Spec.Sum.dsum_type_of_tag", "LowParse.Spec.Sum.parse_dsum_type_of_tag'", "LowParse.Low.Sum.clens_dsum_payload", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.consumed_length", "Prims.unit", "LowParse.Spec.Combinators.synth_injective_synth_inverse_synth_inverse_recip", "LowParse.Spec.Base.refine_with_tag", "LowParse.Spec.Sum.dsum_tag_of_data", "LowParse.Spec.Sum.synth_dsum_case", "LowParse.Spec.Sum.synth_dsum_case_recip", "LowParse.Spec.Sum.synth_dsum_case_injective", "LowParse.Spec.Sum.synth_dsum_case_inverse", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Sum.parse_dsum_eq3", "LowParse.Low.Base.Spec.gaccessor'" ]
[]
false
false
false
false
false
let gaccessor_clens_dsum_payload' (#kt: parser_kind) (t: dsum) (p: parser kt (dsum_repr_type t)) (f: (x: dsum_known_key t -> Tot (k: parser_kind & parser k (dsum_type_of_known_tag t x)))) (#ku: parser_kind) (g: parser ku (dsum_type_of_unknown_tag t)) (k: dsum_key t) : Tot (gaccessor' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k)) =
fun (input: bytes) -> parse_dsum_eq3 t p f g input; let res = match parse p input with | Some (_, consumed) -> synth_dsum_case_inverse t k; synth_dsum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_dsum_case t k) (synth_dsum_case_recip t k) (); (consumed) | _ -> (0) in (res <: (res: _ { gaccessor_post' (parse_dsum t p f g) (parse_dsum_type_of_tag' t f g k) (clens_dsum_payload t k) input res }))
false
Pulse.Checker.Return.fst
Pulse.Checker.Return.check_effect
val check_effect (#g: env) (#e: term) (#eff: T.tot_or_ghost) (#t: term) (d: typing g e eff t) (c: option ctag) : T.Tac (c: ctag & e: term & typing g e (eff_of_ctag c) t)
val check_effect (#g: env) (#e: term) (#eff: T.tot_or_ghost) (#t: term) (d: typing g e eff t) (c: option ctag) : T.Tac (c: ctag & e: term & typing g e (eff_of_ctag c) t)
let check_effect (#g:env) (#e:term) (#eff:T.tot_or_ghost) (#t:term) (d:typing g e eff t) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = match c, eff with | None, T.E_Total -> (| STT_Atomic, e, d |) | None, T.E_Ghost -> (| STT_Ghost, e, d |) | Some STT_Ghost, T.E_Total -> (| STT_Atomic, e, d |) | Some STT_Ghost, T.E_Ghost -> (| STT_Ghost, e, d |) | _, T.E_Total -> (| STT_Atomic, e, d |) | _ -> fail g (Some e.range) "Expected a total term, but this term has Ghost effect"
{ "file_name": "lib/steel/pulse/Pulse.Checker.Return.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 81, "end_line": 46, "start_col": 0, "start_line": 29 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Return open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Return.fst" }
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: Pulse.Typing.typing g e eff t -> c: FStar.Pervasives.Native.option Pulse.Syntax.Base.ctag -> FStar.Tactics.Effect.Tac (FStar.Pervasives.dtuple3 Pulse.Syntax.Base.ctag (fun _ -> Pulse.Syntax.Base.term) (fun c e -> Pulse.Typing.typing g e (Pulse.Typing.eff_of_ctag c) t))
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "Pulse.Typing.typing", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.ctag", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Mkdtuple3", "Pulse.Typing.eff_of_ctag", "Pulse.Syntax.Base.STT_Atomic", "FStar.Pervasives.dtuple3", "Pulse.Syntax.Base.STT_Ghost", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.range", "Pulse.Syntax.Base.__proj__Mkterm__item__range" ]
[]
false
true
false
false
false
let check_effect (#g: env) (#e: term) (#eff: T.tot_or_ghost) (#t: term) (d: typing g e eff t) (c: option ctag) : T.Tac (c: ctag & e: term & typing g e (eff_of_ctag c) t) =
match c, eff with | None, T.E_Total -> (| STT_Atomic, e, d |) | None, T.E_Ghost -> (| STT_Ghost, e, d |) | Some STT_Ghost, T.E_Total -> (| STT_Atomic, e, d |) | Some STT_Ghost, T.E_Ghost -> (| STT_Ghost, e, d |) | _, T.E_Total -> (| STT_Atomic, e, d |) | _ -> fail g (Some e.range) "Expected a total term, but this term has Ghost effect"
false
Pulse.Checker.Return.fst
Pulse.Checker.Return.check
val check (g:env) (ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_Return? st.term }) (check:check_t) : T.Tac (checker_result_t g ctxt post_hint)
val check (g:env) (ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_Return? st.term }) (check:check_t) : T.Tac (checker_result_t g ctxt post_hint)
let check (g:env) (ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_Return? st.term }) (check:check_t) : T.Tac (checker_result_t g ctxt post_hint) = let Tm_Return f = st.term in match Pulse.Checker.Base.is_stateful_application g f.term with | Some st_app -> check g ctxt ctxt_typing post_hint res_ppname st_app | None -> ( match post_hint with | Some p -> ( check_core g ctxt ctxt_typing post_hint res_ppname st (Some <| ctag_of_effect_annot p.effect_annot) ) | _ -> check_core g ctxt ctxt_typing post_hint res_ppname st None )
{ "file_name": "lib/steel/pulse/Pulse.Checker.Return.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 159, "start_col": 0, "start_line": 138 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Return open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory let check_effect (#g:env) (#e:term) (#eff:T.tot_or_ghost) (#t:term) (d:typing g e eff t) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = match c, eff with | None, T.E_Total -> (| STT_Atomic, e, d |) | None, T.E_Ghost -> (| STT_Ghost, e, d |) | Some STT_Ghost, T.E_Total -> (| STT_Atomic, e, d |) | Some STT_Ghost, T.E_Ghost -> (| STT_Ghost, e, d |) | _, T.E_Total -> (| STT_Atomic, e, d |) | _ -> fail g (Some e.range) "Expected a total term, but this term has Ghost effect" let check_tot_or_ghost_term (g:env) (e:term) (t:term) (c:option ctag) : T.Tac (c:ctag & e:term & typing g e (eff_of_ctag c) t) = let (| e, eff, d |) = check_term_at_type g e t in check_effect d c noeq type result_of_typing (g:env) = | R : c:ctag -> t:term -> u:universe -> ty:term -> universe_of g ty u -> typing g t (eff_of_ctag c) ty -> result_of_typing g let compute_tot_or_ghost_term_type_and_u (g:env) (e:term) (c:option ctag) : T.Tac (result_of_typing g) = let (| t, eff, ty, (| u, ud |), d |) = compute_term_type_and_u g e in let (| c, e, d |) = check_effect d c in R c e u ty ud d #push-options "--z3rlimit_factor 4" let check_core (g:env) (ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_Return? st.term }) (ctag_ctxt:option ctag) : T.Tac (checker_result_t g ctxt post_hint) = let g = push_context "check_return" st.range g in let Tm_Return {expected_type; insert_eq=use_eq; term=t} = st.term in let return_type : option (ty:term & u:universe & universe_of g ty u) = match post_hint with | Some post -> assert (g `env_extends` post.g); let ty_typing : universe_of g post.ret_ty post.u = Metatheory.tot_typing_weakening_standard post.g post.ty_typing g in Some (| post.ret_ty, post.u, ty_typing |) | _ -> match expected_type.t with | Tm_Unknown -> None | _ -> let ty, _ = Pulse.Checker.Pure.instantiate_term_implicits g expected_type in let (| u, d |) = check_universe g ty in Some (| ty, u, d |) in let R c t u ty uty d : result_of_typing g = match return_type with | None -> compute_tot_or_ghost_term_type_and_u g t ctag_ctxt | Some (| ret_ty, u, ty_typing |) -> let (| c, t, d |) = check_tot_or_ghost_term g t ret_ty ctag_ctxt in R c t u ret_ty ty_typing d in let x = fresh g in let px = res_ppname, x in let (| post_opened, post_typing |) : t:term & tot_typing (push_binding g x (fst px) ty) t tm_vprop = match post_hint with | None -> let (| t, ty |) = check_tot_term (push_binding g x (fst px) ty) tm_emp tm_vprop in (| t, ty |) | Some post -> // we already checked for the return type let post : post_hint_t = post in if x `Set.mem` (freevars post.post) then fail g None ("check_return: unexpected variable clash in return post,\ please file a bug report") else let ty_rec = post_hint_typing g post x in (| open_term_nv post.post px, ty_rec.post_typing |) in assume (open_term (close_term post_opened x) x == post_opened); let post = close_term post_opened x in let d = T_Return g c use_eq u ty t post x uty d post_typing in let dd = (match_comp_res_with_post_hint d post_hint) in debug g (fun _ -> let (| _, c, _ |) = dd in Printf.sprintf "Return comp is: %s" (Pulse.Syntax.Printer.comp_to_string c)); prove_post_hint #g (try_frame_pre #g ctxt_typing dd res_ppname) post_hint t.range #pop-options
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Return.fst" }
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> ctxt: Pulse.Syntax.Base.term -> ctxt_typing: Pulse.Typing.tot_typing g ctxt Pulse.Syntax.Base.tm_vprop -> post_hint: Pulse.Typing.post_hint_opt g -> res_ppname: Pulse.Syntax.Base.ppname -> st: Pulse.Syntax.Base.st_term{Tm_Return? (Mkst_term?.term st)} -> check: Pulse.Checker.Base.check_t -> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g ctxt post_hint)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.post_hint_opt", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.st_term", "Prims.b2t", "Pulse.Syntax.Base.uu___is_Tm_Return", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Checker.Base.check_t", "Pulse.Syntax.Base.st_term'__Tm_Return__payload", "Pulse.Checker.Base.checker_result_t", "Pulse.Typing.post_hint_t", "Pulse.Checker.Return.check_core", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.ctag", "Pulse.Syntax.Base.ctag_of_effect_annot", "Pulse.Typing.__proj__Mkpost_hint_t__item__effect_annot", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "Pulse.Checker.Base.is_stateful_application", "Pulse.Syntax.Base.__proj__Mkst_term'__Tm_Return__payload__item__term", "Pulse.Syntax.Base.st_term'" ]
[]
false
true
false
false
false
let check (g: env) (ctxt: term) (ctxt_typing: tot_typing g ctxt tm_vprop) (post_hint: post_hint_opt g) (res_ppname: ppname) (st: st_term{Tm_Return? st.term}) (check: check_t) : T.Tac (checker_result_t g ctxt post_hint) =
let Tm_Return f = st.term in match Pulse.Checker.Base.is_stateful_application g f.term with | Some st_app -> check g ctxt ctxt_typing post_hint res_ppname st_app | None -> (match post_hint with | Some p -> (check_core g ctxt ctxt_typing post_hint res_ppname st (Some <| ctag_of_effect_annot p.effect_annot)) | _ -> check_core g ctxt ctxt_typing post_hint res_ppname st None)
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_sum_payload_no_lookahead
val gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl': bytes) : Lemma (requires ((parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl')) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl'))
val gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl': bytes) : Lemma (requires ((parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl')) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl'))
let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( (parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_strong_prefix (parse_sum t p pc) sl sl' ; parse_injective p sl sl'
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 857, "start_col": 0, "start_line": 839 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32" let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } )) #push-options "--z3rlimit 64" let gaccessor_clens_sum_payload_injective (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ injective_precond (parse_sum t p pc) sl sl' )) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) = parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl' ; parse_injective (parse_sum t p pc) sl sl' ; parse_injective p sl sl' #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.sum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.sum_repr_type t) -> pc: (x: LowParse.Spec.Sum.sum_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.sum_type_of_tag t x))) -> k: LowParse.Spec.Sum.sum_key t -> sl: LowParse.Bytes.bytes -> sl': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires Mkparser_kind'?.parser_kind_subkind (LowParse.Spec.Sum.parse_sum_kind kt t pc) == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.Sum.parse_sum t p pc) (FStar.Pervasives.dsnd (pc k)) (LowParse.Low.Sum.clens_sum_payload t k) sl /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.Sum.parse_sum t p pc) (FStar.Pervasives.dsnd (pc k)) (LowParse.Low.Sum.clens_sum_payload t k) sl' /\ LowParse.Spec.Base.no_lookahead_on_precond (LowParse.Spec.Sum.parse_sum t p pc) sl sl') (ensures LowParse.Low.Sum.gaccessor_clens_sum_payload' t p pc k sl == LowParse.Low.Sum.gaccessor_clens_sum_payload' t p pc k sl')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Sum.sum", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.sum_repr_type", "LowParse.Spec.Sum.sum_key", "Prims.dtuple2", "LowParse.Spec.Sum.sum_type_of_tag", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse_injective", "Prims.unit", "LowParse.Spec.Base.parse_strong_prefix", "LowParse.Spec.Sum.parse_sum_kind", "LowParse.Spec.Sum.sum_type", "LowParse.Spec.Sum.parse_sum", "LowParse.Spec.Sum.parse_sum_eq''", "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", "LowParse.Low.Base.Spec.gaccessor_pre", "Prims.__proj__Mkdtuple2__item___1", "FStar.Pervasives.dsnd", "LowParse.Low.Sum.clens_sum_payload", "LowParse.Spec.Base.no_lookahead_on_precond", "Prims.squash", "Prims.nat", "LowParse.Low.Sum.gaccessor_clens_sum_payload'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gaccessor_clens_sum_payload_no_lookahead (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (sl sl': bytes) : Lemma (requires ((parse_sum_kind kt t pc).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl /\ gaccessor_pre (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) sl' /\ no_lookahead_on_precond (parse_sum t p pc) sl sl')) (ensures (gaccessor_clens_sum_payload' t p pc k sl == gaccessor_clens_sum_payload' t p pc k sl')) =
parse_sum_eq'' t p pc sl; parse_sum_eq'' t p pc sl'; parse_strong_prefix (parse_sum t p pc) sl sl'; parse_injective p sl sl'
false
Steel.ArrayArith.fsti
Steel.ArrayArith.within_bounds_intro
val within_bounds_intro (#a: Type) (#p1 #pp #p2: perm) (arr1 p arr2: array a) : Steel bool (((varrayp arr1 p1) `star` (varrayp p pp)) `star` (varrayp arr2 p2)) (fun _ -> ((varrayp arr1 p1) `star` (varrayp p pp)) `star` (varrayp arr2 p2)) (requires fun h0 -> same_base_array arr1 arr2) (ensures fun h0 r h1 -> (if r then within_bounds arr1 p arr2 else True) /\ aselp arr1 p1 h1 == aselp arr1 p1 h0 /\ aselp p pp h1 == aselp p pp h0 /\ aselp arr2 p2 h1 == aselp arr2 p2 h0)
val within_bounds_intro (#a: Type) (#p1 #pp #p2: perm) (arr1 p arr2: array a) : Steel bool (((varrayp arr1 p1) `star` (varrayp p pp)) `star` (varrayp arr2 p2)) (fun _ -> ((varrayp arr1 p1) `star` (varrayp p pp)) `star` (varrayp arr2 p2)) (requires fun h0 -> same_base_array arr1 arr2) (ensures fun h0 r h1 -> (if r then within_bounds arr1 p arr2 else True) /\ aselp arr1 p1 h1 == aselp arr1 p1 h0 /\ aselp p pp h1 == aselp p pp h0 /\ aselp arr2 p2 h1 == aselp arr2 p2 h0)
let within_bounds_intro (#a: Type) (#p1 #pp #p2: perm) (arr1 p arr2: array a) : Steel bool (varrayp arr1 p1 `star` varrayp p pp `star` varrayp arr2 p2) (fun _ -> varrayp arr1 p1 `star` varrayp p pp `star` varrayp arr2 p2) (requires fun h0 -> same_base_array arr1 arr2) (ensures fun h0 r h1 -> (if r then within_bounds arr1 p arr2 else True) /\ aselp arr1 p1 h1 == aselp arr1 p1 h0 /\ aselp p pp h1 == aselp p pp h0 /\ aselp arr2 p2 h1 == aselp arr2 p2 h0 ) = let s1 = elim_varrayp arr1 p1 in let s2 = elim_varrayp arr2 p2 in let sp = elim_varrayp p pp in change_equal_slprop (pts_to arr1 p1 _) (pts_to (| ptr_of arr1, Ghost.hide (length arr1) |) p1 _); change_equal_slprop (pts_to p pp _) (pts_to (| ptr_of p, Ghost.hide (length p) |) pp _); change_equal_slprop (pts_to arr2 _ _) (pts_to (| ptr_of arr2, Ghost.hide (length arr2) |) p2 _); let b = within_bounds_ptr (ptr_of arr1) (ptr_of p) (ptr_of arr2) (length arr1) (length arr2) (length p) s1 s2 sp in change_equal_slprop (pts_to (| ptr_of arr1, Ghost.hide (length arr1) |) _ _) (pts_to arr1 _ _) ; change_equal_slprop (pts_to (| ptr_of p, Ghost.hide (length p) |) _ _) (pts_to p _ _); change_equal_slprop (pts_to (| ptr_of arr2, Ghost.hide (length arr2) |) _ _) (pts_to arr2 _ _); intro_varrayp arr1 p1 s1; intro_varrayp arr2 p2 s2; intro_varrayp p pp sp; return b
{ "file_name": "lib/steel/Steel.ArrayArith.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 72, "start_col": 0, "start_line": 46 }
module Steel.ArrayArith open Steel.FractionalPermission open Steel.Effect.Atomic open Steel.Effect open Steel.ST.Array open Steel.Array (* This module provides a very restricted way of doing pointer arithmetic comparison on Steel arrays. Primitives in this module are considered builtins by karamel, and have handwritten C implementations. Clients using this module should extract with the krml options `-static-header Steel.ArrayArith -no-prefix Steel.ArrayArith` *) /// The main predicate of this module. `within_bounds` captures that [p] is part of the same /// allocation unit as [arr1] and [arr2], and situated in between. It is an abstract predicate, /// that can only be introduced by the `within_bounds_intro` function below. val within_bounds (#a: Type) (arr1 p arr2: array a) : prop /// An abbreviation capturing that [arr1] and [arr2] belong to the same array, /// and hence to the same allocation unit according to the Steel memory model unfold let same_base_array (#a:Type) (arr1 arr2: array a) : prop = base (ptr_of arr1) == base (ptr_of arr2) /// The only way to introduce the `within_bounds` predicate. /// To fit inside the C standard, we require all three arrays to be live. /// Furthermore, pointer comparison when pointers belong to different /// allocation units is undefined according to the C standard, see section 6.5.8 /// of https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2912.pdf. Instead, this /// function will be primitively extracted to C as a comparison on uintptr_t, /// i.e. (uintptr_t) arr1 <= (uintptr_t) p && (uintptr_t) p <= (uintptr_t) arr2 val within_bounds_ptr (#a :Type) (#p1 #p2 #pp:perm) (arr1 p arr2: ptr a) (len1: Ghost.erased nat { offset arr1 + len1 <= base_len (base arr1) }) (len2: Ghost.erased nat { offset arr2 + len2 <= base_len (base arr2) }) (lenp: Ghost.erased nat { offset p + lenp <= base_len (base p) }) (s1 s2 sp: Ghost.erased (Seq.seq a)) : Steel bool (pts_to (| arr1, len1 |) p1 s1 `star` pts_to (| arr2, len2 |) p2 s2 `star` pts_to (| p, lenp |) pp sp) (fun _ -> pts_to (| arr1, len1 |) p1 s1 `star` pts_to (| arr2, len2 |) p2 s2 `star` pts_to (| p, lenp |) pp sp) (requires fun _ -> base arr1 == base arr2) (ensures fun _ r _ -> if r then within_bounds (| arr1, len1 |) (| p, lenp |) (| arr2, len2 |) else True) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "Steel.Array.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ArrayArith.fsti" }
[ { "abbrev": false, "full_module": "Steel.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
arr1: Steel.ST.Array.array a -> p: Steel.ST.Array.array a -> arr2: Steel.ST.Array.array a -> Steel.Effect.Steel Prims.bool
Steel.Effect.Steel
[]
[]
[ "Steel.FractionalPermission.perm", "Steel.ST.Array.array", "Steel.Effect.Atomic.return", "Prims.bool", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.VStar", "Steel.Array.varrayp", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Array.intro_varrayp", "FStar.Ghost.reveal", "FStar.Seq.Base.seq", "Steel.Effect.Atomic.change_equal_slprop", "Steel.ST.Array.pts_to", "Prims.Mkdtuple2", "Steel.ST.Array.ptr", "FStar.Ghost.erased", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "Steel.ST.Array.base_len", "Steel.ST.Array.base", "Steel.ST.Array.ptr_of", "Steel.ST.Array.length", "Steel.ArrayArith.within_bounds_ptr", "Steel.Array.elim_varrayp", "Steel.Effect.Common.star", "Steel.Effect.Common.rmem", "Steel.ArrayArith.same_base_array", "Prims.l_and", "Steel.ArrayArith.within_bounds", "Prims.l_True", "Prims.logical", "Prims.eq2", "FStar.Seq.Properties.lseq", "Steel.Array.aselp" ]
[]
false
true
false
false
false
let within_bounds_intro (#a: Type) (#p1 #pp #p2: perm) (arr1 p arr2: array a) : Steel bool (((varrayp arr1 p1) `star` (varrayp p pp)) `star` (varrayp arr2 p2)) (fun _ -> ((varrayp arr1 p1) `star` (varrayp p pp)) `star` (varrayp arr2 p2)) (requires fun h0 -> same_base_array arr1 arr2) (ensures fun h0 r h1 -> (if r then within_bounds arr1 p arr2 else True) /\ aselp arr1 p1 h1 == aselp arr1 p1 h0 /\ aselp p pp h1 == aselp p pp h0 /\ aselp arr2 p2 h1 == aselp arr2 p2 h0) =
let s1 = elim_varrayp arr1 p1 in let s2 = elim_varrayp arr2 p2 in let sp = elim_varrayp p pp in change_equal_slprop (pts_to arr1 p1 _) (pts_to (| ptr_of arr1, Ghost.hide (length arr1) |) p1 _); change_equal_slprop (pts_to p pp _) (pts_to (| ptr_of p, Ghost.hide (length p) |) pp _); change_equal_slprop (pts_to arr2 _ _) (pts_to (| ptr_of arr2, Ghost.hide (length arr2) |) p2 _); let b = within_bounds_ptr (ptr_of arr1) (ptr_of p) (ptr_of arr2) (length arr1) (length arr2) (length p) s1 s2 sp in change_equal_slprop (pts_to (| ptr_of arr1, Ghost.hide (length arr1) |) _ _) (pts_to arr1 _ _); change_equal_slprop (pts_to (| ptr_of p, Ghost.hide (length p) |) _ _) (pts_to p _ _); change_equal_slprop (pts_to (| ptr_of arr2, Ghost.hide (length arr2) |) _ _) (pts_to arr2 _ _); intro_varrayp arr1 p1 s1; intro_varrayp arr2 p2 s2; intro_varrayp p pp sp; return b
false
LowParse.Low.Sum.fst
LowParse.Low.Sum.gaccessor_clens_sum_payload'
val gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k))
val gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k))
let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) = fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 // dummy in (res <: (res: _ { gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res } ))
{ "file_name": "src/lowparse/LowParse.Low.Sum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 108, "end_line": 814, "start_col": 0, "start_line": 796 }
module LowParse.Low.Sum include LowParse.Low.Enum include LowParse.Spec.Sum module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 inline_for_extraction let validate_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in validate_synth (validate_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let validate_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = validator (parse_sum_cases t pc k) let validate_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : validate_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let validate_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (validate_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (validate_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (validate_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let validate_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (validate_sum_cases_t t pc)) (k: sum_key t) : Tot (validator (parse_sum_cases t pc k)) = destr _ (validate_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_cases_aux t pc vc) k inline_for_extraction let validate_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U64.t) -> HST.Stack U64.t (requires (fun h -> live_slice h input /\ U64.v pos <= U32.v input.len)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> is_error res | Known k' -> if is_success res then valid_pos (dsnd (pc k')) h input (uint64_to_uint32 pos) (uint64_to_uint32 res) else (~ (valid (dsnd (pc k')) h input (uint64_to_uint32 pos))) ))) let validate_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k -> validate_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let validate_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (validate_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (validate_sum_aux_payload_t t pc k))) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: validate_sum_aux_payload_t t pc k) input pos end else (iff () <: validate_sum_aux_payload_t t pc k) input pos inline_for_extraction let validate_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (validate_sum_aux_payload_eq t pc k)) = validate_sum_aux_payload_if' t pc k #push-options "--z3rlimit 64 --z3cliopt smt.arith.nl=false --using_facts_from '* -FStar.Int.Cast -LowParse.BitFields'" // --query_stats --smtencoding.elim_box true --smtencoding.l_arith_repr native --z3refresh" inline_for_extraction let validate_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (validator (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = parse_sum_eq'' t p pc (bytes_of_slice_from h input (uint64_to_uint32 pos)) in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p h input (uint64_to_uint32 pos) in let len_after_tag = v input pos in if is_error len_after_tag then len_after_tag else begin let h1 = HST.get () in let k' = p32 input (uint64_to_uint32 pos) in [@inline_let] let _ = match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input (uint64_to_uint32 len_after_tag) | _ -> () in v_payload k' input len_after_tag end #pop-options inline_for_extraction let validate_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (validate_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos // validate_synth (pc32 k) (synth_sum_case t k) () input pos | _ -> validator_error_generic inline_for_extraction let validate_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (validate_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (validate_sum_aux_payload_eq t pc) (validate_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (validate_sum_aux_payload' t pc pc32) k inline_for_extraction let validate_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: validator p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (validator (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (validate_sum_aux_payload_t t pc)) : Tot (validator (parse_sum t p pc)) = validate_sum_aux t v p32 pc (validate_sum_aux_payload t pc pc32 destr) module HS = FStar.HyperStack #push-options "--z3rlimit 256 --z3cliopt smt.arith.nl=false --initial_ifuel 8 --max_ifuel 8 --initial_fuel 2 --max_fuel 2" #restart-solver let valid_sum_intro (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_enum_key p (sum_enum t)) h input pos /\ ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in valid (dsnd (pc k)) h input (get_valid_pos (parse_enum_key p (sum_enum t)) h input pos) ))) (ensures ( let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_content_pos (parse_sum t p pc) h input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = contents (parse_enum_key p (sum_enum t)) h input pos in let pos_payload = get_valid_pos (parse_enum_key p (sum_enum t)) h input pos in valid_facts (dsnd (pc k)) h input pos_payload; valid_facts (parse_sum t p pc) h input pos; parse_sum_eq t p pc (bytes_of_slice_from h input pos) #pop-options inline_for_extraction let finalize_sum_case (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (s: serializer p) (w: leaf_writer_strong s) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (destr: enum_repr_of_key'_t (sum_enum t)) (k: sum_key t) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack unit (requires (fun h -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in U32.v pos + len_tag < 4294967296 /\ ( let pos_payload = pos `U32.add` U32.uint_to_t len_tag in valid (dsnd (pc k)) h input pos_payload /\ writable input.base (U32.v pos) (U32.v pos_payload) h ))) (ensures (fun h _ h' -> let len_tag = serialized_length (serialize_enum_key _ s (sum_enum t)) k in let pos_payload = pos `U32.add` U32.uint_to_t len_tag in B.modifies (loc_slice_from_to input pos pos_payload) h h' /\ valid_content_pos (parse_sum t p pc) h' input pos (synth_sum_case t k (contents (dsnd (pc k)) h input pos_payload)) (get_valid_pos (dsnd (pc k)) h input pos_payload) )) = let pos1 = write_enum_key w (sum_enum t) destr k input pos in let h = HST.get () in [@inline_let] let _ = valid_sum_intro h t p pc input pos in () inline_for_extraction let jump_sum_cases_aux (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in jump_synth (jump_weaken (weaken_parse_cases_kind t pc) (vc k) () ) (synth_sum_case t k) () inline_for_extraction let jump_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = jumper (parse_sum_cases t pc k) let jump_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : jump_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let jump_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (jump_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (jump_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (jump_sum_cases_t t pc k)) #rrel #rel input pos -> if cond then sv_true () input pos else sv_false () input pos inline_for_extraction let jump_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (vc: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (jump_sum_cases_t t pc)) (k: sum_key t) : Tot (jumper (parse_sum_cases t pc k)) = destr _ (jump_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_cases_aux t pc vc) k inline_for_extraction let jump_sum_aux_payload_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot Type = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack U32.t (requires (fun h -> live_slice h input /\ U32.v pos <= U32.v input.len /\ ( match k with | Unknown _ -> False | Known k' -> valid (dsnd (pc k')) h input pos ))) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ ( match k with | Unknown _ -> False | Known k' -> valid_pos (dsnd (pc k')) h input pos res ))) let jump_sum_aux_payload_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k -> jump_sum_aux_payload_t t pc k -> GTot Type0) = fun _ _ -> True inline_for_extraction let jump_sum_aux_payload_if' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) (cond: bool) (ift: ((cond_true cond) -> Tot (jump_sum_aux_payload_t t pc k))) (iff: ((cond_false cond) -> Tot (jump_sum_aux_payload_t t pc k))) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> if cond then begin (ift () <: jump_sum_aux_payload_t t pc k) input pos end else (iff () <: jump_sum_aux_payload_t t pc k) input pos inline_for_extraction let jump_sum_aux_payload_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: maybe_enum_key (sum_enum t)) : Tot (if_combinator _ (jump_sum_aux_payload_eq t pc k)) = jump_sum_aux_payload_if' t pc k let parse_sum_eq3 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k))) (ensures ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) | _ -> False end )) = parse_sum_eq'' t p pc input let parse_sum_eq4 (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (input: bytes) (k' : sum_repr_type t) (consumed_k: consumed_length input) (consumed_payload: nat) : Lemma (requires (Some? (parse (parse_sum t p pc) input) /\ parse p input == Some (k', consumed_k) /\ ( let input_k = Seq.slice input consumed_k (Seq.length input) in let k = maybe_enum_key_of_repr (sum_enum t) k' in begin match k with | Known k -> Some? (parse (dsnd (pc k)) input_k) /\ ( let Some (_, consumed_payload') = parse (dsnd (pc k)) input_k in consumed_payload' == consumed_payload ) | _ -> False end ))) (ensures ( let Some (_, consumed) = parse (parse_sum t p pc) input in consumed == consumed_k + consumed_payload )) = parse_sum_eq'' t p pc input #push-options "--z3rlimit 16" let valid_sum_elim (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid p h input pos /\ ( let pos_payload = get_valid_pos p h input pos in let k' = maybe_enum_key_of_repr (sum_enum t) (contents p h input pos) in match k' with | Known k -> k == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) /\ valid (dsnd (pc k)) h input pos_payload /\ valid_pos (parse_sum t p pc) h input pos (get_valid_pos (dsnd (pc k)) h input pos_payload) | _ -> False ))) = let sinput = bytes_of_slice_from h input pos in let _ = parse_sum_eq'' t p pc sinput in [@inline_let] let _ = valid_facts (parse_sum t p pc) h input pos in let Some (k', consumed_k) = parse p sinput in let pos_after_tag = U32.uint_to_t (U32.v pos + consumed_k) in [@inline_let] let _ = valid_facts p h input pos in assert (valid_content_pos p h input pos k' pos_after_tag); match maybe_enum_key_of_repr (sum_enum t) k' with | Known k -> valid_facts (dsnd (pc k)) h input pos_after_tag | _ -> () #pop-options let valid_sum_elim_tag (h: HS.mem) (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid (parse_sum t p pc) h input pos )) (ensures ( valid (parse_enum_key p (sum_enum t)) h input pos /\ contents (parse_enum_key p (sum_enum t)) h input pos == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let _ = parse_sum_eq' t p pc (bytes_of_slice_from h input pos) in let _ = valid_facts (parse_sum t p pc) h input pos in let _ = valid_facts (parse_enum_key p (sum_enum t)) h input pos in () inline_for_extraction let read_sum_tag (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (p32: leaf_reader p) (destr: dep_maybe_enum_destr_t (sum_enum t) (read_enum_key_t (sum_enum t))) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack (sum_key t) (requires (fun h -> valid (parse_sum t p pc) h input pos )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == sum_tag_of_data t (contents (parse_sum t p pc) h input pos) )) = let h = HST.get () in [@inline_let] let _ = valid_sum_elim_tag h t p pc input pos in read_enum_key p32 (sum_enum t) destr input pos inline_for_extraction let jump_sum_aux (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (v_payload: ((k: sum_repr_type t)) -> Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k))) : Tot (jumper (parse_sum t p pc)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_sum_elim h t p pc input pos in let pos_after_tag = v input pos in let k' = p32 input pos in v_payload k' input pos_after_tag inline_for_extraction let jump_sum_aux_payload' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (k: maybe_enum_key (sum_enum t)) : Tot (jump_sum_aux_payload_t t pc k) = fun #rrel #rel input pos -> match k with | Known k -> [@inline_let] let _ = synth_sum_case_injective t k in pc32 k input pos | _ -> 0ul // dummy, but we MUST NOT remove this branch, otherwise extraction fails inline_for_extraction let jump_sum_aux_payload (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) (k: sum_repr_type t) : Tot (jump_sum_aux_payload_t t pc (maybe_enum_key_of_repr (sum_enum t) k)) = destr (jump_sum_aux_payload_eq t pc) (jump_sum_aux_payload_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (jump_sum_aux_payload' t pc pc32) k inline_for_extraction let jump_sum (t: sum) (#kt: parser_kind) (#p: parser kt (sum_repr_type t)) (v: jumper p) (p32: leaf_reader p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (jumper (dsnd (pc x))))) (destr: dep_maybe_enum_destr_t (sum_enum t) (jump_sum_aux_payload_t t pc)) : Tot (jumper (parse_sum t p pc)) = jump_sum_aux t v p32 pc (jump_sum_aux_payload t pc pc32 destr) inline_for_extraction let read_sum_cases' (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = [@inline_let] let _ = synth_sum_case_injective t k in read_synth' (dsnd (pc k)) (synth_sum_case t k) (pc32 k) () inline_for_extraction let read_sum_cases_t (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot Type = leaf_reader (parse_sum_cases' t pc k) let read_sum_cases_t_eq (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) (x y : read_sum_cases_t t pc k) : GTot Type0 = True inline_for_extraction let read_sum_cases_t_if (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (if_combinator _ (read_sum_cases_t_eq t pc k)) = fun cond (sv_true: cond_true cond -> Tot (read_sum_cases_t t pc k)) (sv_false: cond_false cond -> Tot (read_sum_cases_t t pc k)) #_ #_ input pos -> if cond then (sv_true () input pos) else (sv_false () input pos) inline_for_extraction let read_sum_cases (t: sum) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) (k: sum_key t) : Tot (leaf_reader (parse_sum_cases' t pc k)) = destr _ (read_sum_cases_t_if t pc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (read_sum_cases' t pc pc32) k #push-options "--z3rlimit 32" inline_for_extraction let read_sum (#kt: parser_kind) (t: sum) (p: parser kt (sum_repr_type t)) (p32: leaf_reader (parse_enum_key p (sum_enum t))) (j: jumper p) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (pc32: ((x: sum_key t) -> Tot (leaf_reader (dsnd (pc x))))) (destr: dep_enum_destr (sum_enum t) (read_sum_cases_t t pc)) : Tot (leaf_reader (parse_sum t p pc)) = fun #_ #_ input pos -> let h = HST.get () in valid_facts (parse_sum t p pc) h input pos; parse_sum_eq' t p pc (bytes_of_slice_from h input pos); valid_facts (parse_enum_key p (sum_enum t)) h input pos; let k = p32 input pos in let pos' = jump_enum_key j (sum_enum t) input pos in valid_facts (parse_sum_cases' t pc k) h input pos' ; read_sum_cases t pc pc32 destr k input pos' #pop-options inline_for_extraction let serialize32_sum_cases_t (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot Type = serializer32 (serialize_sum_cases t pc sc k) let serialize32_sum_cases_t_eq (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) (x y: serialize32_sum_cases_t t sc k) : GTot Type0 = True inline_for_extraction let serialize32_sum_cases_t_if (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (k: sum_key t) : Tot (if_combinator _ (serialize32_sum_cases_t_eq t sc k)) = fun cond (sv_true: (cond_true cond -> Tot (serialize32_sum_cases_t t sc k))) (sv_false: (cond_false cond -> Tot (serialize32_sum_cases_t t sc k))) x #rrel #rel b pos -> if cond then (sv_true () x b pos) else (sv_false () x b pos) inline_for_extraction let serialize32_sum_cases_aux (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = fun x #rrel #rel b pos -> [@inline_let] let _ = Classical.forall_intro (parse_sum_cases_eq' t pc k); synth_sum_case_injective t k; synth_sum_case_inverse t k in serialize32_synth (sc32 k) (synth_sum_case t k) (synth_sum_case_recip t k) (fun x -> synth_sum_case_recip t k x) () x b pos inline_for_extraction let serialize32_sum_cases (t: sum) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) (k: sum_key t) : Tot (serializer32 (serialize_sum_cases t pc sc k)) = destr _ (serialize32_sum_cases_t_if t sc) (fun _ _ -> ()) (fun _ _ _ _ -> ()) (serialize32_sum_cases_aux t sc sc32) k inline_for_extraction let serialize32_sum (#kt: parser_kind) (t: sum) (#p: parser kt (sum_repr_type t)) (s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (s32: serializer32 (serialize_enum_key _ s (sum_enum t))) (#pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (sc: ((x: sum_key t) -> Tot (serializer (dsnd (pc x))))) (sc32: ((x: sum_key t) -> Tot (serializer32 (sc x)))) (destr: dep_enum_destr (sum_enum t) (serialize32_sum_cases_t t sc)) : Tot (serializer32 (serialize_sum t s sc)) = fun x #rrel #rel b pos -> serialize_sum_eq t s sc x; let tg = sum_tag_of_data t x in serialize32_nondep_then_aux s32 (serialize32_sum_cases t sc sc32 destr tg) tg x b pos let clens_sum_tag (s: sum) : Tot (clens (sum_type s) (sum_key s)) = { clens_cond = (fun _ -> True); clens_get = sum_tag_of_data s; } let gaccessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (gaccessor (parse_sum t p pc) (parse_enum_key p (sum_enum t)) (clens_sum_tag t)) = gaccessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) inline_for_extraction let accessor_sum_tag (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: ((x: sum_key t) -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) : Tot (accessor (gaccessor_sum_tag t p pc)) = accessor_tagged_union_tag (parse_enum_key p (sum_enum t)) (sum_tag_of_data t) (parse_sum_cases t pc) let clens_sum_payload (s: sum) (k: sum_key s) : Tot (clens (sum_type s) (sum_type_of_tag s k)) = { clens_cond = (fun (x: sum_type s) -> sum_tag_of_data s x == k); clens_get = (fun (x: sum_type s) -> synth_sum_case_recip s k x <: Ghost (sum_type_of_tag s k) (requires (sum_tag_of_data s x == k)) (ensures (fun _ -> True))); } #push-options "--z3rlimit 32"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Sum.fst.checked", "LowParse.Low.Enum.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Sum.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.Sum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: LowParse.Spec.Sum.sum -> p: LowParse.Spec.Base.parser kt (LowParse.Spec.Sum.sum_repr_type t) -> pc: (x: LowParse.Spec.Sum.sum_key t -> Prims.dtuple2 LowParse.Spec.Base.parser_kind (fun k -> LowParse.Spec.Base.parser k (LowParse.Spec.Sum.sum_type_of_tag t x))) -> k: LowParse.Spec.Sum.sum_key t -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.Sum.parse_sum t p pc) (FStar.Pervasives.dsnd (pc k)) (LowParse.Low.Sum.clens_sum_payload t k)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Sum.sum", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Sum.sum_repr_type", "LowParse.Spec.Sum.sum_key", "Prims.dtuple2", "LowParse.Spec.Sum.sum_type_of_tag", "LowParse.Bytes.bytes", "Prims.nat", "LowParse.Low.Base.Spec.gaccessor_post'", "LowParse.Spec.Sum.parse_sum_kind", "LowParse.Spec.Sum.sum_type", "LowParse.Spec.Sum.parse_sum", "Prims.__proj__Mkdtuple2__item___1", "FStar.Pervasives.dsnd", "LowParse.Low.Sum.clens_sum_payload", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.consumed_length", "Prims.unit", "LowParse.Spec.Combinators.synth_injective_synth_inverse_synth_inverse_recip", "LowParse.Spec.Sum.sum_cases", "LowParse.Spec.Sum.synth_sum_case", "LowParse.Spec.Sum.synth_sum_case_recip", "LowParse.Spec.Sum.synth_sum_case_injective", "LowParse.Spec.Sum.synth_sum_case_inverse", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Sum.parse_sum_eq''", "LowParse.Low.Base.Spec.gaccessor'" ]
[]
false
false
false
false
false
let gaccessor_clens_sum_payload' (t: sum) (#kt: parser_kind) (p: parser kt (sum_repr_type t)) (pc: (x: sum_key t -> Tot (k: parser_kind & parser k (sum_type_of_tag t x)))) (k: sum_key t) : Tot (gaccessor' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k)) =
fun (input: bytes) -> parse_sum_eq'' t p pc input; let res = match parse p input with | Some (_, consumed) -> synth_sum_case_inverse t k; synth_sum_case_injective t k; synth_injective_synth_inverse_synth_inverse_recip (synth_sum_case t k) (synth_sum_case_recip t k) (); (consumed) | _ -> 0 in (res <: (res: _{gaccessor_post' (parse_sum t p pc) (dsnd (pc k)) (clens_sum_payload t k) input res}))
false
LowParse.Low.BoundedInt.fst
LowParse.Low.BoundedInt.div256
val div256 (x: U32.t) : Tot (y: U32.t{U32.v y == U32.v x / 256})
val div256 (x: U32.t) : Tot (y: U32.t{U32.v y == U32.v x / 256})
let div256 (x: U32.t) : Tot (y: U32.t { U32.v y == U32.v x / 256 }) = assert_norm (pow2 8 == 256); FStar.UInt.shift_right_value_lemma #32 (U32.v x) 8; x `U32.shift_right` 8ul
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 32, "start_col": 0, "start_line": 29 }
module LowParse.Low.BoundedInt open LowParse.Low.Combinators module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module E = LowParse.Endianness.BitFields module BF = LowParse.BitFields module LE = LowParse.Low.Endianness module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction let mul256 (x: U16.t) : Tot (y: U32.t { U32.v y == 256 `Prims.op_Multiply` U16.v x }) = assert_norm (pow2 8 == 256); FStar.Math.Lemmas.pow2_lt_compat 32 24; FStar.Math.Lemmas.pow2_lt_compat 24 16; FStar.Math.Lemmas.pow2_lt_compat 16 8; FStar.Math.Lemmas.pow2_plus 8 16; FStar.Math.Lemmas.small_mod (U16.v x `Prims.op_Multiply` 256) (pow2 32); FStar.UInt.shift_left_value_lemma #32 (U16.v x) 8; Cast.uint16_to_uint32 x `U32.shift_left` 8ul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.Low.Endianness.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowParse.Low.BoundedInt.fst" }
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Low.Endianness", "short_module": "LE" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "LowParse.Endianness.BitFields", "short_module": "E" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> y: FStar.UInt32.t{FStar.UInt32.v y == FStar.UInt32.v x / 256}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "FStar.UInt32.shift_right", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.UInt.shift_right_value_lemma", "FStar.UInt32.v", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Prims.op_Division" ]
[]
false
false
false
false
false
let div256 (x: U32.t) : Tot (y: U32.t{U32.v y == U32.v x / 256}) =
assert_norm (pow2 8 == 256); FStar.UInt.shift_right_value_lemma #32 (U32.v x) 8; x `U32.shift_right` 8ul
false
SteelFramingTestSuite.fst
SteelFramingTestSuite.test_if9
val test_if9 (b: bool) (r1 r2: ref) : SteelT unit ((ptr r1) `star` (ptr r2)) (fun _ -> (ptr r1) `star` (ptr r2))
val test_if9 (b: bool) (r1 r2: ref) : SteelT unit ((ptr r1) `star` (ptr r2)) (fun _ -> (ptr r1) `star` (ptr r2))
let test_if9 (b:bool) (r1 r2: ref) : SteelT unit (ptr r1 `star` ptr r2) (fun _ -> ptr r1 `star` ptr r2) = write r1 0; if b then (write r1 0) else (write r2 0); write r2 0; if b then (write r1 0) else (write r2 0); write r1 0
{ "file_name": "share/steel/tests/SteelFramingTestSuite.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 154, "start_col": 0, "start_line": 147 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module SteelFramingTestSuite open Steel.Memory open Steel.Effect /// A collection of small unit tests for the framing tactic assume val p : vprop assume val f (x:int) : SteelT unit p (fun _ -> p) let test () : SteelT unit (p `star` p `star` p) (fun _ -> p `star` p `star` p) = f 0; () assume val ref : Type0 assume val ptr (_:ref) : vprop assume val alloc (x:int) : SteelT ref emp (fun y -> ptr y) assume val free (r:ref) : SteelT unit (ptr r) (fun _ -> emp) assume val read (r:ref) : SteelT int (ptr r) (fun _ -> ptr r) assume val write (r:ref) (v: int) : SteelT unit (ptr r) (fun _ -> ptr r) let unused x = x // work around another gensym heisenbug let test0 (b1 b2 b3: ref) : SteelT int (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b1 `star` ptr b2 `star` ptr b3) = let x = read b1 in x let test1 (b1 b2 b3: ref) : SteelT int (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b1 `star` ptr b2 `star` ptr b3) = let x = (let y = read b1 in y) in x let test2 (b1 b2 b3: ref) : SteelT int (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b3 `star` ptr b2 `star` ptr b1) = let x = read b1 in x let test3 (b1 b2 b3: ref) : SteelT int (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b2 `star` ptr b1 `star` ptr b3) = let x = read b3 in x let test4 (b1 b2 b3: ref) : SteelT unit (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b2 `star` ptr b1 `star` ptr b3) = let x = read b3 in write b2 x let test5 (b1 b2 b3: ref) : SteelT unit (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b2 `star` ptr b1 `star` ptr b3) = let x = read b3 in write b2 (x + 1) let test6 (b1 b2 b3: ref) : SteelT unit (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b2 `star` ptr b1 `star` ptr b3) = let x = read b3 in let b4 = alloc x in write b2 (x + 1); free b4 // With the formalism relying on can_be_split_post, this example fails if we normalize return_pre eqs goals before unification // When solving this equality, we have the goal // (*?u19*) _ _ == return_pre ((fun x -> (fun x -> (*?u758*) _ x x) x) r) // with x and r in the context of ?u19 // Not normalizing allows us to solve it as a function applied to x and r // Normalizing would lead to solve it to an slprop with x and r in the context, // but which would later fail when trying to prove the equivalence with (fun r -> ptr r) // in the postcondition let test7 (_:unit) : SteelT ref emp ptr = let r = alloc 0 in let x = read r in write r 0; r let test8 (b1 b2 b3:ref) : SteelT unit (ptr b1 `star` ptr b2 `star` ptr b3) (fun _ -> ptr b2 `star` ptr b1 `star` ptr b3) = write b2 0 open Steel.Effect.Atomic let test_if1 (b:bool) : SteelT unit emp (fun _ -> emp) = if b then noop () else noop () let test_if2 (b:bool) (r: ref) : SteelT unit (ptr r) (fun _ -> ptr r) = if b then write r 0 else write r 1 let test_if3 (b:bool) (r:ref) : SteelT unit (ptr r) (fun _ -> ptr r) = if b then noop () else noop () let test_if4 (b:bool) : SteelT unit emp (fun _ -> emp) = if b then (let r = alloc 0 in free r) else (noop ()) let test_if5 (b:bool) : SteelT ref emp (fun r -> ptr r) = if b then alloc 0 else alloc 1 let test_if6 (b:bool) : SteelT ref emp (fun r -> ptr r) = let r = if b then alloc 0 else alloc 1 in let x = read r in write r 0; r (* First test with different (but equivalent) slprops in both branches *) let test_if7 (b:bool) (r1 r2: ref) : SteelT unit (ptr r1 `star` ptr r2) (fun _ -> ptr r1 `star` ptr r2) = if b then (write r1 0; write r2 0) else (write r2 0; write r1 0); write r2 0 (* Test with different slprops in both branches. The second branch captures the outer frame in its context *) let test_if8 (b:bool) (r1 r2: ref) : SteelT unit (ptr r1 `star` ptr r2) (fun _ -> ptr r1 `star` ptr r2) = if b then (write r1 0; write r2 0) else (write r2 0); write r2 0
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "SteelFramingTestSuite.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Prims.bool -> r1: SteelFramingTestSuite.ref -> r2: SteelFramingTestSuite.ref -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Prims.bool", "SteelFramingTestSuite.ref", "SteelFramingTestSuite.write", "Prims.unit", "Steel.Effect.Common.star", "SteelFramingTestSuite.ptr", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let test_if9 (b: bool) (r1 r2: ref) : SteelT unit ((ptr r1) `star` (ptr r2)) (fun _ -> (ptr r1) `star` (ptr r2)) =
write r1 0; if b then (write r1 0) else (write r2 0); write r2 0; if b then (write r1 0) else (write r2 0); write r1 0
false