effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
FStar.Tactics.Effect.Tac
val instantiate (fa x: term) : Tac binding
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
val instantiate (fa x: term) : Tac binding let instantiate (fa x: term) : Tac binding =
true
null
false
try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.try_with", "FStar.Tactics.NamedView.binding", "Prims.unit", "FStar.Tactics.V2.Derived.pose", "Prims.exn", "FStar.Tactics.V2.Derived.fail" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instantiate (fa x: term) : Tac binding
[]
FStar.Tactics.V2.Logic.instantiate
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
fa: FStar.Tactics.NamedView.term -> x: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
{ "end_col": 32, "end_line": 296, "start_col": 4, "start_line": 294 }
FStar.Tactics.Effect.Tac
val elim_exists (t: term) : Tac (binding & binding)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf)
val elim_exists (t: term) : Tac (binding & binding) let elim_exists (t: term) : Tac (binding & binding) =
true
null
false
apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.NamedView.binding", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Data.binding", "FStar.Tactics.V2.Builtins.intro", "Prims.unit", "FStar.Tactics.V2.Derived.apply_lemma" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val elim_exists (t: term) : Tac (binding & binding)
[]
FStar.Tactics.V2.Logic.elim_exists
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding)
{ "end_col": 9, "end_line": 282, "start_col": 2, "start_line": 279 }
FStar.Tactics.Effect.Tac
val and_elim (t: term) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end
val and_elim (t: term) : Tac unit let and_elim (t: term) : Tac unit =
true
null
false
try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t)))
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.try_with", "Prims.unit", "FStar.Tactics.V2.Derived.apply_lemma", "Prims.exn" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit =
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val and_elim (t: term) : Tac unit
[]
FStar.Tactics.V2.Logic.and_elim
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 51, "end_line": 258, "start_col": 5, "start_line": 257 }
FStar.Tactics.Effect.Tac
val using_lemma (t: term) : Tac binding
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let using_lemma (t : term) : Tac binding = try pose_lemma (`(lem1_fa (`#t))) with | _ -> try pose_lemma (`(lem2_fa (`#t))) with | _ -> try pose_lemma (`(lem3_fa (`#t))) with | _ -> fail "using_lemma: failed to instantiate"
val using_lemma (t: term) : Tac binding let using_lemma (t: term) : Tac binding =
true
null
false
try pose_lemma (`(lem1_fa (`#t))) with | _ -> try pose_lemma (`(lem2_fa (`#t))) with | _ -> try pose_lemma (`(lem3_fa (`#t))) with | _ -> fail "using_lemma: failed to instantiate"
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.try_with", "FStar.Tactics.NamedView.binding", "Prims.unit", "FStar.Tactics.V2.Logic.pose_lemma", "Prims.exn", "FStar.Tactics.V2.Derived.fail" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:list binding) (b:binding) : Tac (list binding & binding) = focus (fun () -> try apply_lemma (`(sklem0 (`#b))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = vars_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x private let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l' private let lem2_fa #a #b #pre #post ($lem : (x:a -> y:b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x:a) (y:b). pre x y ==> post x y) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l' private let lem3_fa #a #b #c #pre #post ($lem : (x:a -> y:b -> z:c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x:a) (y:b) (z:c). pre x y z ==> post x y z) = let l' x y z : Lemma (pre x y z ==> post x y z) = Classical.move_requires (lem x y) z in Classical.forall_intro_3 l' (** Add a lemma into the local context, quantified for all arguments. Only works for lemmas with up to 3 arguments for now. It is expected that `t` is a top-level name, this has not been battle-tested for other kinds of terms. *)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val using_lemma (t: term) : Tac binding
[]
FStar.Tactics.V2.Logic.using_lemma
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
{ "end_col": 43, "end_line": 378, "start_col": 2, "start_line": 375 }
FStar.Tactics.Effect.Tac
val cases_bool (b: term) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ())
val cases_bool (b: term) : Tac unit let cases_bool (b: term) : Tac unit =
true
null
false
let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ())
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.seq", "Prims.unit", "FStar.Tactics.V2.Derived.apply_lemma", "FStar.Reflection.V2.Derived.mk_e_app", "Prims.Cons", "FStar.Reflection.Types.term", "Prims.Nil", "FStar.Pervasives.Native.option", "FStar.Tactics.V2.Derived.trytac", "FStar.Tactics.V2.Builtins.clear_top", "FStar.Tactics.V2.Builtins.rewrite", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.implies_intro" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = ()
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cases_bool (b: term) : Tac unit
[]
FStar.Tactics.V2.Logic.cases_bool
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 104, "end_line": 229, "start_col": 36, "start_line": 226 }
FStar.Tactics.Effect.Tac
val unsquash (t: term) : Tac term
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b)
val unsquash (t: term) : Tac term let unsquash (t: term) : Tac term =
true
null
false
let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.NamedView.pack", "FStar.Tactics.NamedView.Tv_Var", "FStar.Tactics.V2.SyntaxCoercions.binding_to_namedv", "FStar.Reflection.V2.Data.binding", "FStar.Tactics.V2.Builtins.intro", "Prims.unit", "FStar.Tactics.V2.Derived.apply_lemma", "FStar.Reflection.V2.Derived.mk_e_app", "Prims.Cons", "FStar.Reflection.Types.term", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val unsquash (t: term) : Tac term
[]
FStar.Tactics.V2.Logic.unsquash
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term
{ "end_col": 19, "end_line": 209, "start_col": 36, "start_line": 205 }
FStar.Tactics.Effect.Tac
val cases_or (o: term) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o])
val cases_or (o: term) : Tac unit let cases_or (o: term) : Tac unit =
true
null
false
apply_lemma (mk_e_app (`or_ind) [o])
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.apply_lemma", "FStar.Reflection.V2.Derived.mk_e_app", "Prims.Cons", "FStar.Reflection.Types.term", "Prims.Nil", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = ()
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cases_or (o: term) : Tac unit
[]
FStar.Tactics.V2.Logic.cases_or
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
o: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 40, "end_line": 219, "start_col": 4, "start_line": 219 }
FStar.Tactics.Effect.Tac
val explode: Prims.unit -> Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))]))
val explode: Prims.unit -> Tac unit let explode () : Tac unit =
true
null
false
ignore (repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))]) )
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.unit", "FStar.Pervasives.ignore", "FStar.Tactics.V2.Derived.repeatseq", "FStar.Tactics.V2.Derived.first", "Prims.Cons", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.l_intro", "FStar.Tactics.V2.Logic.split", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val explode: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Logic.explode
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 64, "end_line": 135, "start_col": 4, "start_line": 133 }
FStar.Tactics.Effect.Tac
val instantiate_as (fa x: term) (s: string) : Tac binding
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s
val instantiate_as (fa x: term) (s: string) : Tac binding let instantiate_as (fa x: term) (s: string) : Tac binding =
true
null
false
let b = instantiate fa x in rename_to b s
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "Prims.string", "FStar.Tactics.V2.Builtins.rename_to", "FStar.Reflection.V2.Data.binding", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.instantiate" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instantiate_as (fa x: term) (s: string) : Tac binding
[]
FStar.Tactics.V2.Logic.instantiate_as
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
fa: FStar.Tactics.NamedView.term -> x: FStar.Tactics.NamedView.term -> s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
{ "end_col": 17, "end_line": 300, "start_col": 70, "start_line": 298 }
FStar.Pervasives.Lemma
val lem2_fa (#a #b #pre #post: _) ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let lem2_fa #a #b #pre #post ($lem : (x:a -> y:b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x:a) (y:b). pre x y ==> post x y) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l'
val lem2_fa (#a #b #pre #post: _) ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y) let lem2_fa #a #b #pre #post ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y) =
false
null
true
let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l'
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "lemma" ]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_2", "Prims.l_imp", "Prims.l_True", "FStar.Classical.move_requires", "Prims.l_Forall" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:list binding) (b:binding) : Tac (list binding & binding) = focus (fun () -> try apply_lemma (`(sklem0 (`#b))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = vars_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x private let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l' private let lem2_fa #a #b #pre #post
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lem2_fa (#a #b #pre #post: _) ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y)
[]
FStar.Tactics.V2.Logic.lem2_fa
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
$lem: (x: a -> y: b -> FStar.Pervasives.Lemma (requires pre x y) (ensures post x y)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b). pre x y ==> post x y)
{ "end_col": 29, "end_line": 359, "start_col": 52, "start_line": 355 }
FStar.Pervasives.Lemma
val lem3_fa (#a #b #c #pre #post: _) ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let lem3_fa #a #b #c #pre #post ($lem : (x:a -> y:b -> z:c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x:a) (y:b) (z:c). pre x y z ==> post x y z) = let l' x y z : Lemma (pre x y z ==> post x y z) = Classical.move_requires (lem x y) z in Classical.forall_intro_3 l'
val lem3_fa (#a #b #c #pre #post: _) ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z) let lem3_fa #a #b #c #pre #post ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z) =
false
null
true
let l' x y z : Lemma (pre x y z ==> post x y z) = Classical.move_requires (lem x y) z in Classical.forall_intro_3 l'
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "lemma" ]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_3", "Prims.l_imp", "Prims.l_True", "FStar.Classical.move_requires", "Prims.l_Forall" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:list binding) (b:binding) : Tac (list binding & binding) = focus (fun () -> try apply_lemma (`(sklem0 (`#b))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = vars_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x private let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l' private let lem2_fa #a #b #pre #post ($lem : (x:a -> y:b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x:a) (y:b). pre x y ==> post x y) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l' private let lem3_fa #a #b #c #pre #post
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lem3_fa (#a #b #c #pre #post: _) ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z)
[]
FStar.Tactics.V2.Logic.lem3_fa
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
$lem: (x: a -> y: b -> z: c -> FStar.Pervasives.Lemma (requires pre x y z) (ensures post x y z)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b) (z: c). pre x y z ==> post x y z)
{ "end_col": 29, "end_line": 368, "start_col": 62, "start_line": 364 }
FStar.Tactics.Effect.Tac
val pose_lemma (t: term) : Tac binding
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b
val pose_lemma (t: term) : Tac binding let pose_lemma (t: term) : Tac binding =
true
null
false
let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in let post = norm_term [] post in match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Reflection.Types.term", "FStar.Tactics.V2.Derived.pose", "FStar.Tactics.NamedView.binding", "FStar.Reflection.V2.Formula.formula", "Prims.unit", "FStar.Pervasives.ignore", "FStar.Pervasives.Native.option", "FStar.Tactics.V2.Derived.trytac", "FStar.Tactics.V2.Derived.trivial", "FStar.Tactics.V2.Derived.flip", "FStar.Tactics.V2.SyntaxCoercions.binding_to_term", "FStar.Tactics.V2.Derived.tcut", "FStar.Reflection.V2.Formula.term_as_formula'", "FStar.Tactics.V2.Derived.norm_term", "Prims.Nil", "FStar.Pervasives.norm_step", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.comp_view", "FStar.Tactics.V2.Derived.fail", "FStar.Tactics.NamedView.comp", "FStar.Tactics.NamedView.tcc", "FStar.Reflection.Types.env", "FStar.Tactics.V2.Derived.cur_env" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h ()
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pose_lemma (t: term) : Tac binding
[]
FStar.Tactics.V2.Logic.pose_lemma
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
{ "end_col": 5, "end_line": 130, "start_col": 41, "start_line": 111 }
FStar.Tactics.Effect.Tac
val sk_binder' (acc: list binding) (b: binding) : Tac (list binding & binding)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let rec sk_binder' (acc:list binding) (b:binding) : Tac (list binding & binding) = focus (fun () -> try apply_lemma (`(sklem0 (`#b))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) )
val sk_binder' (acc: list binding) (b: binding) : Tac (list binding & binding) let rec sk_binder' (acc: list binding) (b: binding) : Tac (list binding & binding) =
true
null
false
focus (fun () -> try (apply_lemma (`(sklem0 (`#b))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx :: acc) b') with | _ -> (acc, b))
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.list", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Derived.focus", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V2.Derived.try_with", "FStar.Tactics.V2.Logic.sk_binder'", "Prims.Cons", "FStar.Tactics.V2.Logic.implies_intro", "FStar.Tactics.V2.Logic.forall_intro", "FStar.Tactics.V2.Builtins.clear", "FStar.Tactics.V2.Derived.fail", "Prims.bool", "Prims.op_disEquality", "Prims.int", "FStar.Tactics.V2.Derived.ngoals", "FStar.Tactics.V2.Derived.apply_lemma", "FStar.Reflection.Types.term", "FStar.Tactics.V2.SyntaxCoercions.binding_to_term", "Prims.exn", "FStar.Pervasives.Native.Mktuple2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sk_binder' (acc: list binding) (b: binding) : Tac (list binding & binding)
[ "recursion" ]
FStar.Tactics.V2.Logic.sk_binder'
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
acc: Prims.list FStar.Tactics.NamedView.binding -> b: FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac (Prims.list FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding)
{ "end_col": 3, "end_line": 318, "start_col": 2, "start_line": 309 }
FStar.Tactics.Effect.Tac
val forall_intro: Prims.unit -> Tac binding
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro ()
val forall_intro: Prims.unit -> Tac binding let forall_intro () : Tac binding =
true
null
false
apply_lemma (`fa_intro_lem); intro ()
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.intro", "FStar.Reflection.V2.Data.binding", "FStar.Tactics.V2.Derived.apply_lemma", "FStar.Tactics.NamedView.binding" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_intro: Prims.unit -> Tac binding
[]
FStar.Tactics.V2.Logic.forall_intro
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
{ "end_col": 12, "end_line": 53, "start_col": 4, "start_line": 52 }
FStar.Tactics.Effect.Tac
val hyp (x: namedv) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x)
val hyp (x: namedv) : Tac unit let hyp (x: namedv) : Tac unit =
true
null
false
l_exact (namedv_to_term x)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.namedv", "FStar.Tactics.V2.Logic.l_exact", "FStar.Tactics.V2.SyntaxCoercions.namedv_to_term", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general...
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hyp (x: namedv) : Tac unit
[]
FStar.Tactics.V2.Logic.hyp
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.Tactics.NamedView.namedv -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 58, "end_line": 105, "start_col": 32, "start_line": 105 }
FStar.Tactics.Effect.Tac
val right: Prims.unit -> Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let right () : Tac unit = apply_lemma (`or_intro_2)
val right: Prims.unit -> Tac unit let right () : Tac unit =
true
null
false
apply_lemma (`or_intro_2)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.apply_lemma" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val right: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Logic.right
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 29, "end_line": 241, "start_col": 4, "start_line": 241 }
FStar.Tactics.Effect.Tac
val visit (callback: (unit -> Tac unit)) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) )
val visit (callback: (unit -> Tac unit)) : Tac unit let rec visit (callback: (unit -> Tac unit)) : Tac unit =
true
null
false
focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> ()))
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.focus", "FStar.Tactics.V2.Derived.or_else", "FStar.Tactics.NamedView.bv", "FStar.Reflection.Types.typ", "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.seq", "FStar.Tactics.V2.Logic.visit", "FStar.Tactics.V2.Logic.l_revert_all", "Prims.list", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.forall_intros", "FStar.Tactics.V2.Logic.split", "FStar.Tactics.V2.Logic.l_revert", "FStar.Tactics.V2.Logic.implies_intro", "FStar.Reflection.V2.Formula.formula", "FStar.Reflection.V2.Formula.term_as_formula", "FStar.Tactics.V2.Derived.cur_goal" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))]))
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val visit (callback: (unit -> Tac unit)) : Tac unit
[ "recursion" ]
FStar.Tactics.V2.Logic.visit
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
callback: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit) -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 11, "end_line": 154, "start_col": 4, "start_line": 138 }
Prims.Tot
val __elim_exists' (#t: _) (#pred: (t -> Type0)) (#goal: _) (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf)
val __elim_exists' (#t: _) (#pred: (t -> Type0)) (#goal: _) (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal let __elim_exists' #t (#pred: (t -> Type0)) #goal (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal =
false
null
true
FStar.Squash.bind_squash #(x: t & pred x) h (fun (| x , pf |) -> k x pf)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "total" ]
[ "Prims.l_Exists", "Prims.squash", "FStar.Squash.bind_squash", "Prims.dtuple2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x))
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val __elim_exists' (#t: _) (#pred: (t -> Type0)) (#goal: _) (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal
[]
FStar.Tactics.V2.Logic.__elim_exists'
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h: (exists (x: t). pred x) -> k: (x: t -> _: pred x -> Prims.squash goal) -> Prims.squash goal
{ "end_col": 70, "end_line": 275, "start_col": 2, "start_line": 275 }
Prims.Tot
val __lemma_to_squash: #req: _ -> #ens: _ -> squash req -> h: (unit -> Lemma (requires req) (ensures ens)) -> squash ens
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h ()
val __lemma_to_squash: #req: _ -> #ens: _ -> squash req -> h: (unit -> Lemma (requires req) (ensures ens)) -> squash ens let __lemma_to_squash #req #ens (_: squash req) (h: (unit -> Lemma (requires req) (ensures ens))) : squash ens =
false
null
true
h ()
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "total" ]
[ "Prims.squash", "Prims.unit", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val __lemma_to_squash: #req: _ -> #ens: _ -> squash req -> h: (unit -> Lemma (requires req) (ensures ens)) -> squash ens
[]
FStar.Tactics.V2.Logic.__lemma_to_squash
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.squash req -> h: (_: Prims.unit -> FStar.Pervasives.Lemma (requires req) (ensures ens)) -> Prims.squash ens
{ "end_col": 6, "end_line": 109, "start_col": 2, "start_line": 109 }
FStar.Pervasives.Lemma
val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let lemma_from_squash #a #b f x = let _ = f x in assert (b x)
val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) let lemma_from_squash #a #b f x =
false
null
true
let _ = f x in assert (b x)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "lemma" ]
[ "Prims.squash", "Prims._assert", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. Pre: goal = G |- e : squash s t : squash r Post: G, x:r |- e : squash s `x` is returned as a term *) let unsquash (t : term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack (Tv_Var b) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binding * binding) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binding = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:list binding) (b:binding) : Tac (list binding & binding) = focus (fun () -> try apply_lemma (`(sklem0 (`#b))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = vars_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x)
[]
FStar.Tactics.V2.Logic.lemma_from_squash
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (x: a -> Prims.squash (b x)) -> x: a -> FStar.Pervasives.Lemma (ensures b x)
{ "end_col": 61, "end_line": 331, "start_col": 33, "start_line": 331 }
FStar.Tactics.Effect.Tac
val l_revert_all (bs: list binding) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end
val l_revert_all (bs: list binding) : Tac unit let rec l_revert_all (bs: list binding) : Tac unit =
true
null
false
match bs with | [] -> () | _ :: tl -> l_revert (); l_revert_all tl
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.list", "FStar.Tactics.NamedView.binding", "Prims.unit", "FStar.Tactics.V2.Logic.l_revert_all", "FStar.Tactics.V2.Logic.l_revert" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val l_revert_all (bs: list binding) : Tac unit
[ "recursion" ]
FStar.Tactics.V2.Logic.l_revert_all
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
bs: Prims.list FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 53, "end_line": 44, "start_col": 4, "start_line": 42 }
FStar.Pervasives.Lemma
val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f)
val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f =
false
null
true
FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "lemma" ]
[ "Prims.squash", "FStar.Classical.give_witness_from_squash", "FStar.Squash.bind_squash", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q
[]
FStar.Tactics.V2.Logic.vbind
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
sq: Prims.squash p -> f: (_: p -> Prims.squash q) -> FStar.Pervasives.Lemma (ensures q)
{ "end_col": 95, "end_line": 191, "start_col": 23, "start_line": 191 }
FStar.Pervasives.Lemma
val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f))
val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f =
false
null
true
FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x: squash a) -> FStar.Squash.bind_squash x f))
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "lemma" ]
[ "Prims.squash", "FStar.Classical.give_witness", "Prims.l_imp", "FStar.Classical.arrow_to_impl", "FStar.Squash.bind_squash", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b)
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b)
[]
FStar.Tactics.V2.Logic.imp_intro_lem
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: a -> Prims.squash b) -> FStar.Pervasives.Lemma (ensures a ==> b)
{ "end_col": 113, "end_line": 76, "start_col": 2, "start_line": 76 }
Prims.Tot
val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x)
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in ()
val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x =
false
null
true
let x:(_: unit{forall x. b x}) = s in ()
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[ "total" ]
[ "Prims.squash", "Prims.l_Forall", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) ->
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x)
[]
FStar.Tactics.V2.Logic.revert_squash
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.squash (forall (x: a). b x) -> x: a -> Prims.squash (b x)
{ "end_col": 71, "end_line": 33, "start_col": 29, "start_line": 33 }
FStar.Tactics.Effect.Tac
val simplify_eq_implication: Prims.unit -> Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication
val simplify_eq_implication: Prims.unit -> Tac unit let rec simplify_eq_implication () : Tac unit =
true
null
false
let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit simplify_eq_implication
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.fail", "FStar.Reflection.V2.Formula.formula", "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Logic.visit", "FStar.Tactics.V2.Logic.simplify_eq_implication", "FStar.Tactics.V2.Builtins.clear_top", "FStar.Tactics.V2.Builtins.rewrite", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.implies_intro", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V2.Derived.destruct_equality_implication", "FStar.Reflection.Types.typ", "FStar.Tactics.V2.Derived.cur_goal", "FStar.Reflection.Types.env", "FStar.Tactics.V2.Derived.cur_env" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) )
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_eq_implication: Prims.unit -> Tac unit
[ "recursion" ]
FStar.Tactics.V2.Logic.simplify_eq_implication
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 37, "end_line": 167, "start_col": 47, "start_line": 156 }
FStar.Tactics.Effect.Tac
val unfold_definition_and_simplify_eq (tm: term) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "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 } ]
false
let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end
val unfold_definition_and_simplify_eq (tm: term) : Tac unit let rec unfold_definition_and_simplify_eq (tm: term) : Tac unit =
true
null
false
let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () | _ -> let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm)
{ "checked_file": "FStar.Tactics.V2.Logic.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Logic.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Reflection.V2.Builtins.term_eq", "FStar.Tactics.V2.Derived.trivial", "Prims.unit", "Prims.bool", "FStar.Reflection.V2.Formula.formula", "FStar.Tactics.V2.Derived.fail", "FStar.Tactics.V2.Logic.visit", "FStar.Tactics.V2.Logic.unfold_definition_and_simplify_eq", "FStar.Tactics.V2.Builtins.clear_top", "FStar.Tactics.V2.Builtins.rewrite", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.implies_intro", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V2.Derived.destruct_equality_implication", "FStar.Reflection.V2.Formula.term_as_formula", "FStar.Reflection.Types.typ", "FStar.Tactics.V2.Derived.cur_goal" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Logic open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.V2.Derived open FStar.Tactics.V2.SyntaxCoercions open FStar.Tactics.NamedView open FStar.Tactics.Util (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binding = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binding = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac (list binding) = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binding = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binding = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac (list binding) = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) // FIXME: should this take a binding? It's less general... // but usually what we want. Coercions could help. let hyp (x:namedv) : Tac unit = l_exact (namedv_to_term x) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binding = let c = tcc (cur_env ()) t in let pre, post = match c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(reqb <: term)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication
false
false
FStar.Tactics.V2.Logic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val unfold_definition_and_simplify_eq (tm: term) : Tac unit
[ "recursion" ]
FStar.Tactics.V2.Logic.unfold_definition_and_simplify_eq
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
tm: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 11, "end_line": 188, "start_col": 64, "start_line": 172 }
Prims.Tot
val bn_mod_slow_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> lbignum t len
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BAM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_slow_precomp #t #len n mu r2 a = let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in res
val bn_mod_slow_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> lbignum t len let bn_mod_slow_precomp #t #len n mu r2 a =
false
null
false
let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in res
{ "checked_file": "Hacl.Spec.Bignum.ModReduction.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModReduction.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.op_Addition", "Hacl.Spec.Bignum.Montgomery.bn_to_mont", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_reduction" ]
[]
module Hacl.Spec.Bignum.ModReduction open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BM = Hacl.Spec.Bignum.Montgomery module BAM = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Modular reduction based on Montgomery arithmetic val bn_mod_slow_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> lbignum t len
false
false
Hacl.Spec.Bignum.ModReduction.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_slow_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> lbignum t len
[]
Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModReduction.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Spec.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t (len + len) -> Hacl.Spec.Bignum.Definitions.lbignum t len
{ "end_col": 5, "end_line": 33, "start_col": 43, "start_line": 30 }
Prims.Pure
val bn_mod_slow: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t (len + len) -> Pure (lbignum t len) (requires 1 < bn_v n /\ bn_v n % 2 = 1 /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res == bn_v a % bn_v n)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BAM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_slow #t #len nBits n a = let r2, mu = BM.bn_mont_precomp nBits n in bn_mod_slow_precomp_lemma n mu r2 a; bn_mod_slow_precomp n mu r2 a
val bn_mod_slow: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t (len + len) -> Pure (lbignum t len) (requires 1 < bn_v n /\ bn_v n % 2 = 1 /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res == bn_v a % bn_v n) let bn_mod_slow #t #len nBits n a =
false
null
false
let r2, mu = BM.bn_mont_precomp nBits n in bn_mod_slow_precomp_lemma n mu r2 a; bn_mod_slow_precomp n mu r2 a
{ "checked_file": "Hacl.Spec.Bignum.ModReduction.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModReduction.fst" }
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_Addition", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp", "Prims.unit", "Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Montgomery.bn_mont_precomp" ]
[]
module Hacl.Spec.Bignum.ModReduction open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BM = Hacl.Spec.Bignum.Montgomery module BAM = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Modular reduction based on Montgomery arithmetic val bn_mod_slow_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> lbignum t len let bn_mod_slow_precomp #t #len n mu r2 a = let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in res val bn_mod_slow_precomp_lemma: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> Lemma (requires BM.bn_mont_pre n mu /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n) (ensures bn_v (bn_mod_slow_precomp n mu r2 a) == bn_v a % bn_v n) let bn_mod_slow_precomp_lemma #t #len n mu r2 a = let r = pow2 (bits t * len) in let d, _ = M.eea_pow2_odd (bits t * len) (bn_v n) in M.mont_preconditions_d (bits t) len (bn_v n); assert (M.mont_pre (bits t) len (bn_v n) (v mu)); let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in BAM.bn_almost_mont_reduction_lemma n mu a; BM.bn_to_mont_lemma n mu r2 a_mod; bn_eval_bound a (len + len); assert (bn_v a < pow2 (bits t * (len + len))); Math.Lemmas.pow2_plus (bits t * len) (bits t * len); assert (bn_v a < r * r); AM.almost_mont_reduction_lemma (bits t) len (bn_v n) (v mu) (bn_v a); assert (bn_v a_mod % bn_v n == bn_v a * d % bn_v n); calc (==) { bn_v res; (==) { M.to_mont_lemma (bits t) len (bn_v n) (v mu) (bn_v a_mod) } bn_v a_mod * r % bn_v n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (bn_v a_mod) r (bn_v n) } bn_v a_mod % bn_v n * r % bn_v n; (==) { } (bn_v a * d % bn_v n) * r % bn_v n; (==) { M.lemma_mont_id1 (bn_v n) r d (bn_v a) } bn_v a % bn_v n; }; assert (bn_v res == bn_v a % bn_v n) val bn_mod_slow: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t (len + len) -> Pure (lbignum t len) (requires 1 < bn_v n /\ bn_v n % 2 = 1 /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res == bn_v a % bn_v n)
false
false
Hacl.Spec.Bignum.ModReduction.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_slow: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t (len + len) -> Pure (lbignum t len) (requires 1 < bn_v n /\ bn_v n % 2 = 1 /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res == bn_v a % bn_v n)
[]
Hacl.Spec.Bignum.ModReduction.bn_mod_slow
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModReduction.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
nBits: Lib.IntTypes.size_nat -> n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t (len + len) -> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len)
{ "end_col": 31, "end_line": 98, "start_col": 35, "start_line": 95 }
FStar.Pervasives.Lemma
val bn_mod_slow_precomp_lemma: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> Lemma (requires BM.bn_mont_pre n mu /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n) (ensures bn_v (bn_mod_slow_precomp n mu r2 a) == bn_v a % bn_v n)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BAM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_slow_precomp_lemma #t #len n mu r2 a = let r = pow2 (bits t * len) in let d, _ = M.eea_pow2_odd (bits t * len) (bn_v n) in M.mont_preconditions_d (bits t) len (bn_v n); assert (M.mont_pre (bits t) len (bn_v n) (v mu)); let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in BAM.bn_almost_mont_reduction_lemma n mu a; BM.bn_to_mont_lemma n mu r2 a_mod; bn_eval_bound a (len + len); assert (bn_v a < pow2 (bits t * (len + len))); Math.Lemmas.pow2_plus (bits t * len) (bits t * len); assert (bn_v a < r * r); AM.almost_mont_reduction_lemma (bits t) len (bn_v n) (v mu) (bn_v a); assert (bn_v a_mod % bn_v n == bn_v a * d % bn_v n); calc (==) { bn_v res; (==) { M.to_mont_lemma (bits t) len (bn_v n) (v mu) (bn_v a_mod) } bn_v a_mod * r % bn_v n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (bn_v a_mod) r (bn_v n) } bn_v a_mod % bn_v n * r % bn_v n; (==) { } (bn_v a * d % bn_v n) * r % bn_v n; (==) { M.lemma_mont_id1 (bn_v n) r d (bn_v a) } bn_v a % bn_v n; }; assert (bn_v res == bn_v a % bn_v n)
val bn_mod_slow_precomp_lemma: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> Lemma (requires BM.bn_mont_pre n mu /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n) (ensures bn_v (bn_mod_slow_precomp n mu r2 a) == bn_v a % bn_v n) let bn_mod_slow_precomp_lemma #t #len n mu r2 a =
false
null
true
let r = pow2 (bits t * len) in let d, _ = M.eea_pow2_odd (bits t * len) (bn_v n) in M.mont_preconditions_d (bits t) len (bn_v n); assert (M.mont_pre (bits t) len (bn_v n) (v mu)); let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in BAM.bn_almost_mont_reduction_lemma n mu a; BM.bn_to_mont_lemma n mu r2 a_mod; bn_eval_bound a (len + len); assert (bn_v a < pow2 (bits t * (len + len))); Math.Lemmas.pow2_plus (bits t * len) (bits t * len); assert (bn_v a < r * r); AM.almost_mont_reduction_lemma (bits t) len (bn_v n) (v mu) (bn_v a); assert (bn_v a_mod % bn_v n == bn_v a * d % bn_v n); calc ( == ) { bn_v res; ( == ) { M.to_mont_lemma (bits t) len (bn_v n) (v mu) (bn_v a_mod) } bn_v a_mod * r % bn_v n; ( == ) { Math.Lemmas.lemma_mod_mul_distr_l (bn_v a_mod) r (bn_v n) } (bn_v a_mod % bn_v n) * r % bn_v n; ( == ) { () } (bn_v a * d % bn_v n) * r % bn_v n; ( == ) { M.lemma_mont_id1 (bn_v n) r d (bn_v a) } bn_v a % bn_v n; }; assert (bn_v res == bn_v a % bn_v n)
{ "checked_file": "Hacl.Spec.Bignum.ModReduction.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModReduction.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.op_Addition", "Prims.int", "Prims._assert", "Prims.eq2", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Modulus", "Prims.unit", "FStar.Calc.calc_finish", "Prims.nat", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.Montgomery.Lemmas.to_mont_lemma", "Lib.IntTypes.bits", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Hacl.Spec.Montgomery.Lemmas.lemma_mont_id1", "Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_reduction_lemma", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.pow2_plus", "Prims.pow2", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Hacl.Spec.Bignum.Montgomery.bn_to_mont_lemma", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_reduction_lemma", "Hacl.Spec.Bignum.Montgomery.bn_to_mont", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_reduction", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "Prims.pos" ]
[]
module Hacl.Spec.Bignum.ModReduction open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BM = Hacl.Spec.Bignum.Montgomery module BAM = Hacl.Spec.Bignum.AlmostMontgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" /// Modular reduction based on Montgomery arithmetic val bn_mod_slow_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> lbignum t len let bn_mod_slow_precomp #t #len n mu r2 a = let a_mod = BAM.bn_almost_mont_reduction n mu a in let res = BM.bn_to_mont n mu r2 a_mod in res val bn_mod_slow_precomp_lemma: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> Lemma (requires BM.bn_mont_pre n mu /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n) (ensures bn_v (bn_mod_slow_precomp n mu r2 a) == bn_v a % bn_v n)
false
false
Hacl.Spec.Bignum.ModReduction.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_slow_precomp_lemma: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t (len + len) -> Lemma (requires BM.bn_mont_pre n mu /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n) (ensures bn_v (bn_mod_slow_precomp n mu r2 a) == bn_v a % bn_v n)
[]
Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModReduction.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Spec.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t (len + len) -> FStar.Pervasives.Lemma (requires Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu /\ Hacl.Spec.Bignum.Definitions.bn_v r2 == Prims.pow2 ((2 * Lib.IntTypes.bits t) * len) % Hacl.Spec.Bignum.Definitions.bn_v n) (ensures Hacl.Spec.Bignum.Definitions.bn_v (Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp n mu r2 a) == Hacl.Spec.Bignum.Definitions.bn_v a % Hacl.Spec.Bignum.Definitions.bn_v n)
{ "end_col": 38, "end_line": 79, "start_col": 49, "start_line": 48 }
Prims.Tot
val from_felem (x: felem) : nat
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let from_felem (x:felem) : nat = x
val from_felem (x: felem) : nat let from_felem (x: felem) : nat =
false
null
false
x
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.felem", "Prims.nat" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val from_felem (x: felem) : nat
[]
Spec.Poly1305.from_felem
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Poly1305.felem -> Prims.nat
{ "end_col": 34, "end_line": 24, "start_col": 33, "start_line": 24 }
Prims.Tot
val poly1305_update1 (r: felem) (len: size_nat{len <= size_block}) (b: lbytes len) (acc: felem) : Tot felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_update1 (r:felem) (len:size_nat{len <= size_block}) (b:lbytes len) (acc:felem) : Tot felem = (encode len b `fadd` acc) `fmul` r
val poly1305_update1 (r: felem) (len: size_nat{len <= size_block}) (b: lbytes len) (acc: felem) : Tot felem let poly1305_update1 (r: felem) (len: size_nat{len <= size_block}) (b: lbytes len) (acc: felem) : Tot felem =
false
null
false
((encode len b) `fadd` acc) `fmul` r
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.felem", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Poly1305.size_block", "Lib.ByteSequence.lbytes", "Spec.Poly1305.fmul", "Spec.Poly1305.fadd", "Spec.Poly1305.encode" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo) let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r let encode (len:size_nat{len <= size_block}) (b:lbytes len) : Tot felem = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b)
false
false
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_update1 (r: felem) (len: size_nat{len <= size_block}) (b: lbytes len) (acc: felem) : Tot felem
[]
Spec.Poly1305.poly1305_update1
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Spec.Poly1305.felem -> len: Lib.IntTypes.size_nat{len <= Spec.Poly1305.size_block} -> b: Lib.ByteSequence.lbytes len -> acc: Spec.Poly1305.felem -> Spec.Poly1305.felem
{ "end_col": 36, "end_line": 57, "start_col": 2, "start_line": 57 }
Prims.Tot
val poly1305_mac (msg: bytes) (k: key) : Tot tag
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_mac (msg:bytes) (k:key) : Tot tag = let acc, r = poly1305_init k in let acc = poly1305_update msg acc r in poly1305_finish k acc
val poly1305_mac (msg: bytes) (k: key) : Tot tag let poly1305_mac (msg: bytes) (k: key) : Tot tag =
false
null
false
let acc, r = poly1305_init k in let acc = poly1305_update msg acc r in poly1305_finish k acc
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Lib.ByteSequence.bytes", "Spec.Poly1305.key", "Spec.Poly1305.felem", "Spec.Poly1305.poly1305_finish", "Spec.Poly1305.poly1305_update", "Spec.Poly1305.tag", "FStar.Pervasives.Native.tuple2", "Spec.Poly1305.poly1305_init" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo) let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r let encode (len:size_nat{len <= size_block}) (b:lbytes len) : Tot felem = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b) let poly1305_update1 (r:felem) (len:size_nat{len <= size_block}) (b:lbytes len) (acc:felem) : Tot felem = (encode len b `fadd` acc) `fmul` r let poly1305_finish (k:key) (acc:felem) : Tot tag = let s = nat_from_bytes_le (slice k 16 32) in let n = (from_felem acc + s) % pow2 128 in nat_to_bytes_le 16 n let poly1305_update_last (r:felem) (l:size_nat{l < 16}) (b:lbytes l) (acc:felem) = if l = 0 then acc else poly1305_update1 r l b acc let poly1305_update (text:bytes) (acc:felem) (r:felem) : Tot felem = repeat_blocks #uint8 #felem size_block text (poly1305_update1 r size_block) (poly1305_update_last r) acc
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_mac (msg: bytes) (k: key) : Tot tag
[]
Spec.Poly1305.poly1305_mac
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
msg: Lib.ByteSequence.bytes -> k: Spec.Poly1305.key -> Spec.Poly1305.tag
{ "end_col": 23, "end_line": 77, "start_col": 48, "start_line": 74 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem = x:nat{x < prime}
let felem =
false
null
false
x: nat{x < prime}
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Spec.Poly1305.prime" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem : Type0
[]
Spec.Poly1305.felem
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 28, "end_line": 19, "start_col": 12, "start_line": 19 }
Prims.Tot
val to_felem (x: nat{x < prime}) : felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let to_felem (x:nat{x < prime}) : felem = x
val to_felem (x: nat{x < prime}) : felem let to_felem (x: nat{x < prime}) : felem =
false
null
false
x
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Spec.Poly1305.prime", "Spec.Poly1305.felem" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime
false
false
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val to_felem (x: nat{x < prime}) : felem
[]
Spec.Poly1305.to_felem
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.nat{x < Spec.Poly1305.prime} -> Spec.Poly1305.felem
{ "end_col": 43, "end_line": 23, "start_col": 42, "start_line": 23 }
Prims.Tot
val prime:pos
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p
val prime:pos let prime:pos =
false
null
false
let p = pow2 130 - 5 in assert_norm (p > 0); p
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_GreaterThan", "Prims.int", "Prims.op_Subtraction", "Prims.pow2" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val prime:pos
[]
Spec.Poly1305.prime
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.pos
{ "end_col": 3, "end_line": 17, "start_col": 17, "start_line": 14 }
Prims.Tot
val zero:felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero : felem = to_felem 0
val zero:felem let zero:felem =
false
null
false
to_felem 0
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.to_felem" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero:felem
[]
Spec.Poly1305.zero
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Poly1305.felem
{ "end_col": 29, "end_line": 25, "start_col": 19, "start_line": 25 }
Prims.Tot
val poly1305_init (k: key) : Tot (felem & felem)
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r
val poly1305_init (k: key) : Tot (felem & felem) let poly1305_init (k: key) : Tot (felem & felem) =
false
null
false
let r = poly1305_encode_r (slice k 0 16) in zero, r
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.key", "FStar.Pervasives.Native.Mktuple2", "Spec.Poly1305.felem", "Spec.Poly1305.zero", "Spec.Poly1305.poly1305_encode_r", "Lib.Sequence.slice", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Poly1305.size_key", "FStar.Pervasives.Native.tuple2" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo)
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_init (k: key) : Tot (felem & felem)
[]
Spec.Poly1305.poly1305_init
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Poly1305.key -> Spec.Poly1305.felem * Spec.Poly1305.felem
{ "end_col": 9, "end_line": 49, "start_col": 49, "start_line": 47 }
Prims.Tot
val fmul (x y: felem) : felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fmul (x:felem) (y:felem) : felem = (x * y) % prime
val fmul (x y: felem) : felem let fmul (x y: felem) : felem =
false
null
false
(x * y) % prime
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.felem", "Prims.op_Modulus", "FStar.Mul.op_Star", "Spec.Poly1305.prime" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime}
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fmul (x y: felem) : felem
[]
Spec.Poly1305.fmul
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Poly1305.felem -> y: Spec.Poly1305.felem -> Spec.Poly1305.felem
{ "end_col": 54, "end_line": 21, "start_col": 39, "start_line": 21 }
Prims.Tot
val size_block:size_nat
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_block : size_nat = 16
val size_block:size_nat let size_block:size_nat =
false
null
false
16
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0
false
false
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_block:size_nat
[]
Spec.Poly1305.size_block
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 30, "end_line": 28, "start_col": 28, "start_line": 28 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_update_last (r:felem) (l:size_nat{l < 16}) (b:lbytes l) (acc:felem) = if l = 0 then acc else poly1305_update1 r l b acc
let poly1305_update_last (r: felem) (l: size_nat{l < 16}) (b: lbytes l) (acc: felem) =
false
null
false
if l = 0 then acc else poly1305_update1 r l b acc
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.felem", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Lib.ByteSequence.lbytes", "Prims.op_Equality", "Prims.int", "Prims.bool", "Spec.Poly1305.poly1305_update1" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo) let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r let encode (len:size_nat{len <= size_block}) (b:lbytes len) : Tot felem = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b) let poly1305_update1 (r:felem) (len:size_nat{len <= size_block}) (b:lbytes len) (acc:felem) : Tot felem = (encode len b `fadd` acc) `fmul` r let poly1305_finish (k:key) (acc:felem) : Tot tag = let s = nat_from_bytes_le (slice k 16 32) in let n = (from_felem acc + s) % pow2 128 in nat_to_bytes_le 16 n
false
false
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_update_last : r: Spec.Poly1305.felem -> l: Lib.IntTypes.size_nat{l < 16} -> b: Lib.ByteSequence.lbytes l -> acc: Spec.Poly1305.felem -> Spec.Poly1305.felem
[]
Spec.Poly1305.poly1305_update_last
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Spec.Poly1305.felem -> l: Lib.IntTypes.size_nat{l < 16} -> b: Lib.ByteSequence.lbytes l -> acc: Spec.Poly1305.felem -> Spec.Poly1305.felem
{ "end_col": 51, "end_line": 65, "start_col": 2, "start_line": 65 }
Prims.Tot
val poly1305_update (text: bytes) (acc r: felem) : Tot felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_update (text:bytes) (acc:felem) (r:felem) : Tot felem = repeat_blocks #uint8 #felem size_block text (poly1305_update1 r size_block) (poly1305_update_last r) acc
val poly1305_update (text: bytes) (acc r: felem) : Tot felem let poly1305_update (text: bytes) (acc r: felem) : Tot felem =
false
null
false
repeat_blocks #uint8 #felem size_block text (poly1305_update1 r size_block) (poly1305_update_last r) acc
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Lib.ByteSequence.bytes", "Spec.Poly1305.felem", "Lib.Sequence.repeat_blocks", "Lib.IntTypes.uint8", "Spec.Poly1305.size_block", "Spec.Poly1305.poly1305_update1", "Spec.Poly1305.poly1305_update_last" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo) let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r let encode (len:size_nat{len <= size_block}) (b:lbytes len) : Tot felem = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b) let poly1305_update1 (r:felem) (len:size_nat{len <= size_block}) (b:lbytes len) (acc:felem) : Tot felem = (encode len b `fadd` acc) `fmul` r let poly1305_finish (k:key) (acc:felem) : Tot tag = let s = nat_from_bytes_le (slice k 16 32) in let n = (from_felem acc + s) % pow2 128 in nat_to_bytes_le 16 n let poly1305_update_last (r:felem) (l:size_nat{l < 16}) (b:lbytes l) (acc:felem) = if l = 0 then acc else poly1305_update1 r l b acc
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_update (text: bytes) (acc r: felem) : Tot felem
[]
Spec.Poly1305.poly1305_update
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
text: Lib.ByteSequence.bytes -> acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> Spec.Poly1305.felem
{ "end_col": 5, "end_line": 72, "start_col": 2, "start_line": 69 }
Prims.Tot
val fadd (x y: felem) : felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fadd (x:felem) (y:felem) : felem = (x + y) % prime
val fadd (x y: felem) : felem let fadd (x y: felem) : felem =
false
null
false
(x + y) % prime
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.felem", "Prims.op_Modulus", "Prims.op_Addition", "Spec.Poly1305.prime" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fadd (x y: felem) : felem
[]
Spec.Poly1305.fadd
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Poly1305.felem -> y: Spec.Poly1305.felem -> Spec.Poly1305.felem
{ "end_col": 54, "end_line": 20, "start_col": 39, "start_line": 20 }
Prims.Tot
val size_key:size_nat
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_key : size_nat = 32
val size_key:size_nat let size_key:size_nat =
false
null
false
32
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *)
false
false
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_key:size_nat
[]
Spec.Poly1305.size_key
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 30, "end_line": 29, "start_col": 28, "start_line": 29 }
Prims.Tot
val poly1305_finish (k: key) (acc: felem) : Tot tag
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_finish (k:key) (acc:felem) : Tot tag = let s = nat_from_bytes_le (slice k 16 32) in let n = (from_felem acc + s) % pow2 128 in nat_to_bytes_le 16 n
val poly1305_finish (k: key) (acc: felem) : Tot tag let poly1305_finish (k: key) (acc: felem) : Tot tag =
false
null
false
let s = nat_from_bytes_le (slice k 16 32) in let n = (from_felem acc + s) % pow2 128 in nat_to_bytes_le 16 n
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.key", "Spec.Poly1305.felem", "Lib.ByteSequence.nat_to_bytes_le", "Lib.IntTypes.SEC", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Spec.Poly1305.from_felem", "Prims.pow2", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Multiply", "Lib.Sequence.length", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.Sequence.slice", "Spec.Poly1305.size_key", "Lib.ByteSequence.nat_from_bytes_le", "Lib.IntTypes.uint_t", "Spec.Poly1305.tag" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo) let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r let encode (len:size_nat{len <= size_block}) (b:lbytes len) : Tot felem = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b) let poly1305_update1 (r:felem) (len:size_nat{len <= size_block}) (b:lbytes len) (acc:felem) : Tot felem = (encode len b `fadd` acc) `fmul` r
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_finish (k: key) (acc: felem) : Tot tag
[]
Spec.Poly1305.poly1305_finish
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Poly1305.key -> acc: Spec.Poly1305.felem -> Spec.Poly1305.tag
{ "end_col": 22, "end_line": 62, "start_col": 51, "start_line": 59 }
Prims.Tot
val encode (len: size_nat{len <= size_block}) (b: lbytes len) : Tot felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encode (len:size_nat{len <= size_block}) (b:lbytes len) : Tot felem = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b)
val encode (len: size_nat{len <= size_block}) (b: lbytes len) : Tot felem let encode (len: size_nat{len <= size_block}) (b: lbytes len) : Tot felem =
false
null
false
Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b)
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Poly1305.size_block", "Lib.ByteSequence.lbytes", "Spec.Poly1305.fadd", "Prims.pow2", "FStar.Mul.op_Star", "Lib.ByteSequence.nat_from_bytes_le", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.op_Addition", "Spec.Poly1305.prime", "FStar.Math.Lemmas.pow2_le_compat", "Spec.Poly1305.felem" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo) let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r
false
false
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encode (len: size_nat{len <= size_block}) (b: lbytes len) : Tot felem
[]
Spec.Poly1305.encode
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_nat{len <= Spec.Poly1305.size_block} -> b: Lib.ByteSequence.lbytes len -> Spec.Poly1305.felem
{ "end_col": 45, "end_line": 54, "start_col": 2, "start_line": 52 }
Prims.Tot
val poly1305_encode_r (rb: block) : Tot felem
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_encode_r (rb:block) : Tot felem = let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo)
val poly1305_encode_r (rb: block) : Tot felem let poly1305_encode_r (rb: block) : Tot felem =
false
null
false
let lo = uint_from_bytes_le (sub rb 0 8) in let hi = uint_from_bytes_le (sub rb 8 8) in let mask0 = u64 0x0ffffffc0fffffff in let mask1 = u64 0x0ffffffc0ffffffc in let lo = lo &. mask0 in let hi = hi &. mask1 in assert_norm (pow2 128 < prime); to_felem (uint_v hi * pow2 64 + uint_v lo)
{ "checked_file": "Spec.Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Poly1305.fst" }
[ "total" ]
[ "Spec.Poly1305.block", "Spec.Poly1305.to_felem", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.IntTypes.uint_v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Spec.Poly1305.prime", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.u64", "Lib.ByteSequence.uint_from_bytes_le", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Spec.Poly1305.size_block", "Spec.Poly1305.felem" ]
[]
module Spec.Poly1305 #reset-options "--z3rlimit 60 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence /// Constants and Types (* Field types and parameters *) let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p let felem = x:nat{x < prime} let fadd (x:felem) (y:felem) : felem = (x + y) % prime let fmul (x:felem) (y:felem) : felem = (x * y) % prime let to_felem (x:nat{x < prime}) : felem = x let from_felem (x:felem) : nat = x let zero : felem = to_felem 0 (* Poly1305 parameters *) let size_block : size_nat = 16 let size_key : size_nat = 32 type block = lbytes size_block type tag = lbytes size_block type key = lbytes size_key /// Specification
false
true
Spec.Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_encode_r (rb: block) : Tot felem
[]
Spec.Poly1305.poly1305_encode_r
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
rb: Spec.Poly1305.block -> Spec.Poly1305.felem
{ "end_col": 44, "end_line": 45, "start_col": 46, "start_line": 37 }
Prims.Tot
val clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t)
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); }
val clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) =
false
null
false
{ clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)) }
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "LowParse.Low.Base.Spec.Mkclens", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "Prims.l_True", "FStar.Pervasives.dfst", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_synth_recip", "LowParse.Low.Base.Spec.clens" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t)
[]
LowParse.Low.IfThenElse.clens_ifthenelse_tag
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> LowParse.Low.Base.Spec.clens (Mkparse_ifthenelse_param?.parse_ifthenelse_t p) (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_t p)
{ "end_col": 95, "end_line": 137, "start_col": 4, "start_line": 136 }
Prims.Tot
val accessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) : Tot (accessor (gaccessor_ifthenelse_payload s b))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let accessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) : Tot (accessor (gaccessor_ifthenelse_payload s b)) = fun #rrel #rel -> accessor_ifthenelse_payload' s j b #rrel #rel
val accessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) : Tot (accessor (gaccessor_ifthenelse_payload s b)) let accessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) : Tot (accessor (gaccessor_ifthenelse_payload s b)) =
false
null
false
fun #rrel #rel -> accessor_ifthenelse_payload' s j b #rrel #rel
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "LowParse.Low.Base.jumper", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "Prims.bool", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Low.IfThenElse.accessor_ifthenelse_payload'", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Low.Base.Spec.__proj__Mkclens__item__clens_cond", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Low.IfThenElse.clens_ifthenelse_payload", "LowParse.Low.Base.Spec.contents", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.eq2", "LowParse.Low.Base.Spec.slice_access", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload", "LowParse.Low.Base.accessor" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 (* dummy *) | _ -> 0 (* dummy *) let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( (parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_strong_prefix (parse_ifthenelse p) sl sl'; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_injective s b x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_no_lookahead s b x)); gaccessor_prop_equiv (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) (gaccessor_ifthenelse_payload' s b); gaccessor_ifthenelse_payload' s b inline_for_extraction let accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_ifthenelse p) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_ifthenelse_payload s b) input pos; valid_facts (parse_ifthenelse p) h input pos; parse_ifthenelse_eq p large; valid_facts p.parse_ifthenelse_tag_parser h input pos in j input pos inline_for_extraction let accessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val accessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) : Tot (accessor (gaccessor_ifthenelse_payload s b))
[]
LowParse.Low.IfThenElse.accessor_ifthenelse_payload
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> j: LowParse.Low.Base.jumper (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) -> b: Prims.bool -> LowParse.Low.Base.accessor (LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload s b)
{ "end_col": 65, "end_line": 292, "start_col": 2, "start_line": 292 }
Prims.Tot
val clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); }
val clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) =
false
null
false
{ clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))) }
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "Prims.bool", "LowParse.Low.Base.Spec.Mkclens", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "Prims.eq2", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "FStar.Pervasives.dfst", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_synth_recip", "FStar.Pervasives.dsnd", "Prims.l_True", "LowParse.Low.Base.Spec.clens" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b))
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b))
[]
LowParse.Low.IfThenElse.clens_ifthenelse_payload
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> b: Prims.bool -> LowParse.Low.Base.Spec.clens (Mkparse_ifthenelse_param?.parse_ifthenelse_t p) (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_t p b)
{ "end_col": 255, "end_line": 174, "start_col": 4, "start_line": 173 }
Prims.Tot
val gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s
val gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) =
false
null
false
gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_tag'", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.IfThenElse.clens_ifthenelse_tag", "LowParse.Low.Base.Spec.gaccessor" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_tag
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.IfThenElse.parse_ifthenelse p) (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) (LowParse.Low.IfThenElse.clens_ifthenelse_tag s)
{ "end_col": 29, "end_line": 155, "start_col": 2, "start_line": 154 }
Prims.Ghost
val gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input)) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed
val gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input)) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res)) let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input)) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res)) =
false
null
false
parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "Prims.bool", "LowParse.Bytes.bytes", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.Base.consumed_length", "Prims.nat", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.parse", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "Prims.unit", "LowParse.Spec.IfThenElse.parse_ifthenelse_parse_tag_payload", "LowParse.Spec.IfThenElse.parse_ifthenelse_eq", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.clens_ifthenelse_payload", "LowParse.Low.Base.Spec.gaccessor_post'" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input)) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload''
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> b: Prims.bool -> input: LowParse.Bytes.bytes -> Prims.Ghost Prims.nat
{ "end_col": 12, "end_line": 192, "start_col": 4, "start_line": 189 }
Prims.Tot
val gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_injective s b x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_no_lookahead s b x)); gaccessor_prop_equiv (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) (gaccessor_ifthenelse_payload' s b); gaccessor_ifthenelse_payload' s b
val gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) let gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) =
false
null
false
Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_injective s b x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_no_lookahead s b x)); gaccessor_prop_equiv (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) (gaccessor_ifthenelse_payload' s b); gaccessor_ifthenelse_payload' s b
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "Prims.bool", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload'", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.clens_ifthenelse_payload", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Spec.Base.no_lookahead_on_precond", "Prims.nat", "FStar.Classical.move_requires", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload_no_lookahead", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Spec.Base.injective_precond", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload_injective", "LowParse.Low.Base.Spec.gaccessor" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 (* dummy *) | _ -> 0 (* dummy *) let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( (parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_strong_prefix (parse_ifthenelse p) sl sl'; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> b: Prims.bool -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.IfThenElse.parse_ifthenelse p) (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) (LowParse.Low.IfThenElse.clens_ifthenelse_payload s b)
{ "end_col": 35, "end_line": 253, "start_col": 2, "start_line": 250 }
FStar.Pervasives.Lemma
val gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl'))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_injective p.parse_ifthenelse_tag_parser sl sl'
val gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) =
false
null
true
parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl'; parse_injective p.parse_ifthenelse_tag_parser sl sl'
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "lemma" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "Prims.bool", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse_injective", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "Prims.unit", "LowParse.Spec.IfThenElse.parse_ifthenelse_parse_tag_payload", "LowParse.Spec.IfThenElse.parse_ifthenelse_eq", "Prims.l_and", "LowParse.Low.Base.Spec.gaccessor_pre", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.clens_ifthenelse_payload", "LowParse.Spec.Base.injective_precond", "Prims.squash", "Prims.eq2", "Prims.nat", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 (* dummy *) | _ -> 0 (* dummy *) let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl' ))
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires (gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl'))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload_injective
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> b: Prims.bool -> sl: LowParse.Bytes.bytes -> sl': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.IfThenElse.parse_ifthenelse p) (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) (LowParse.Low.IfThenElse.clens_ifthenelse_payload s b) sl /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.IfThenElse.parse_ifthenelse p) (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) (LowParse.Low.IfThenElse.clens_ifthenelse_payload s b) sl' /\ LowParse.Spec.Base.injective_precond (LowParse.Spec.IfThenElse.parse_ifthenelse p) sl sl') (ensures LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload' s b sl == LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload' s b sl')
{ "end_col": 54, "end_line": 223, "start_col": 2, "start_line": 219 }
Prims.Tot
val gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 (* dummy *) | _ -> 0
val gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) =
false
null
false
fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 | _ -> 0
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "Prims.bool", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Spec.Base.consumed_length", "Prims.op_Equality", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "FStar.Pervasives.dfst", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkserialize_ifthenelse_param__item__serialize_ifthenelse_synth_recip", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload''", "Prims.nat", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Low.Base.Spec.gaccessor'", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.clens_ifthenelse_payload" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload'
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> b: Prims.bool -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.IfThenElse.parse_ifthenelse p) (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) (LowParse.Low.IfThenElse.clens_ifthenelse_payload s b)
{ "end_col": 12, "end_line": 205, "start_col": 2, "start_line": 199 }
Prims.Tot
val jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (jumper (parse_ifthenelse p))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t
val jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (jumper (parse_ifthenelse p)) let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (jumper (parse_ifthenelse p)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b then vp true input pos_after_t else vp false input pos_after_t
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Low.Base.jumper", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.IfThenElse.test_ifthenelse_tag", "Prims.bool", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "FStar.Classical.move_requires", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "Prims.l_and", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_synth", "LowParse.Low.IfThenElse.valid_ifthenelse_elim", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b))))
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (jumper (parse_ifthenelse p))
[]
LowParse.Low.IfThenElse.jump_ifthenelse
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.IfThenElse.parse_ifthenelse_param -> vt: LowParse.Low.Base.jumper (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) -> test: LowParse.Low.IfThenElse.test_ifthenelse_tag p -> vp: (b: Prims.bool -> LowParse.Low.Base.jumper (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b))) -> LowParse.Low.Base.jumper (LowParse.Spec.IfThenElse.parse_ifthenelse p)
{ "end_col": 33, "end_line": 129, "start_col": 2, "start_line": 120 }
FStar.HyperStack.ST.Stack
val accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos))) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos )) = let h = HST.get () in [@inline_let] let _ = let pos' = get_valid_pos (parse_ifthenelse p) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_ifthenelse_payload s b) input pos; valid_facts (parse_ifthenelse p) h input pos; parse_ifthenelse_eq p large; valid_facts p.parse_ifthenelse_tag_parser h input pos in j input pos
val accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos))) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos)) let accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos))) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos)) =
true
null
false
let h = HST.get () in [@@ inline_let ]let _ = let pos' = get_valid_pos (parse_ifthenelse p) h input pos in let large = bytes_of_slice_from h input pos in slice_access_eq h (gaccessor_ifthenelse_payload s b) input pos; valid_facts (parse_ifthenelse p) h input pos; parse_ifthenelse_eq p large; valid_facts p.parse_ifthenelse_tag_parser h input pos in j input pos
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "LowParse.Low.Base.jumper", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "Prims.bool", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.IfThenElse.parse_ifthenelse_eq", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Low.Base.Spec.slice_access_eq", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.clens_ifthenelse_payload", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload", "LowParse.Bytes.bytes", "LowParse.Slice.bytes_of_slice_from", "LowParse.Low.Base.Spec.get_valid_pos", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.l_and", "LowParse.Low.Base.Spec.valid", "LowParse.Low.Base.Spec.__proj__Mkclens__item__clens_cond", "LowParse.Low.Base.Spec.contents", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "Prims.eq2", "LowParse.Low.Base.Spec.slice_access" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 (* dummy *) | _ -> 0 (* dummy *) let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( (parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_strong_prefix (parse_ifthenelse p) sl sl'; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_injective s b x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_ifthenelse_payload_no_lookahead s b x)); gaccessor_prop_equiv (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) (gaccessor_ifthenelse_payload' s b); gaccessor_ifthenelse_payload' s b inline_for_extraction let accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos) )) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val accessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (j: jumper p.parse_ifthenelse_tag_parser) (b: bool) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> valid (parse_ifthenelse p) h input pos /\ (clens_ifthenelse_payload s b).clens_cond (contents (parse_ifthenelse p) h input pos))) (ensures (fun h pos' h' -> B.modifies B.loc_none h h' /\ pos' == slice_access h (gaccessor_ifthenelse_payload s b) input pos))
[]
LowParse.Low.IfThenElse.accessor_ifthenelse_payload'
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> j: LowParse.Low.Base.jumper (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) -> b: Prims.bool -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack FStar.UInt32.t
{ "end_col": 13, "end_line": 283, "start_col": 1, "start_line": 273 }
Prims.Tot
val accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos
val accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) =
false
null
false
fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Base.Spec.slice_access_eq", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.IfThenElse.clens_ifthenelse_tag", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_tag", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.accessor" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s))
[]
LowParse.Low.IfThenElse.accessor_ifthenelse_tag
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> LowParse.Low.Base.accessor (LowParse.Low.IfThenElse.gaccessor_ifthenelse_tag s)
{ "end_col": 7, "end_line": 165, "start_col": 2, "start_line": 162 }
FStar.Pervasives.Lemma
val gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires ((parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl'))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( (parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_strong_prefix (parse_ifthenelse p) sl sl'; parse_injective p.parse_ifthenelse_tag_parser sl sl'
val gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires ((parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) let gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires ((parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) =
false
null
true
parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl'; parse_strong_prefix (parse_ifthenelse p) sl sl'; parse_injective p.parse_ifthenelse_tag_parser sl sl'
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "lemma" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "Prims.bool", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse_injective", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "Prims.unit", "LowParse.Spec.Base.parse_strong_prefix", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Spec.IfThenElse.parse_ifthenelse_parse_tag_payload", "LowParse.Spec.IfThenElse.parse_ifthenelse_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", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Low.IfThenElse.clens_ifthenelse_payload", "LowParse.Spec.Base.no_lookahead_on_precond", "Prims.squash", "Prims.nat", "LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0 let gaccessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = gaccessor_prop_equiv (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s) (gaccessor_ifthenelse_tag' s); gaccessor_ifthenelse_tag' s inline_for_extraction let accessor_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (accessor (gaccessor_ifthenelse_tag s)) = fun #rrel #rel sl pos -> let h = HST.get () in slice_access_eq h (gaccessor_ifthenelse_tag s) sl pos; pos let clens_ifthenelse_payload (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (clens p.parse_ifthenelse_t (p.parse_ifthenelse_payload_t b)) = { clens_cond = (fun (x: p.parse_ifthenelse_t) -> p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b); clens_get = (fun (x: p.parse_ifthenelse_t) -> dsnd (s.serialize_ifthenelse_synth_recip x) <: Ghost (p.parse_ifthenelse_payload_t b) (requires (p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) == b)) (ensures (fun _ -> True))); } let gaccessor_ifthenelse_payload'' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (input: bytes) : Ghost nat (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input )) (ensures (fun res -> gaccessor_post' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) input res )) = parse_ifthenelse_eq p input; parse_ifthenelse_parse_tag_payload s input; let Some (t, consumed) = parse p.parse_ifthenelse_tag_parser input in consumed let gaccessor_ifthenelse_payload' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) : Tot (gaccessor' (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b)) = fun (input: bytes) -> match parse (parse_ifthenelse p) input with | Some (x, _) -> if p.parse_ifthenelse_tag_cond (dfst (s.serialize_ifthenelse_synth_recip x)) = b then gaccessor_ifthenelse_payload'' s b input else 0 (* dummy *) | _ -> 0 (* dummy *) let gaccessor_ifthenelse_payload_injective (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ injective_precond (parse_ifthenelse p) sl sl' )) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl')) = parse_ifthenelse_eq p sl; parse_ifthenelse_eq p sl'; parse_ifthenelse_parse_tag_payload s sl; parse_ifthenelse_parse_tag_payload s sl' ; parse_injective p.parse_ifthenelse_tag_parser sl sl' let gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl' : bytes) : Lemma (requires ( (parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl' ))
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_payload_no_lookahead (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) (b: bool) (sl sl': bytes) : Lemma (requires ((parse_ifthenelse_kind p).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl /\ gaccessor_pre (parse_ifthenelse p) (dsnd (p.parse_ifthenelse_payload_parser b)) (clens_ifthenelse_payload s b) sl' /\ no_lookahead_on_precond (parse_ifthenelse p) sl sl')) (ensures (gaccessor_ifthenelse_payload' s b sl == gaccessor_ifthenelse_payload' s b sl'))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload_no_lookahead
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> b: Prims.bool -> sl: LowParse.Bytes.bytes -> sl': LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (requires Mkparser_kind'?.parser_kind_subkind (LowParse.Spec.IfThenElse.parse_ifthenelse_kind p) == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.IfThenElse.parse_ifthenelse p) (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) (LowParse.Low.IfThenElse.clens_ifthenelse_payload s b) sl /\ LowParse.Low.Base.Spec.gaccessor_pre (LowParse.Spec.IfThenElse.parse_ifthenelse p) (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) (LowParse.Low.IfThenElse.clens_ifthenelse_payload s b) sl' /\ LowParse.Spec.Base.no_lookahead_on_precond (LowParse.Spec.IfThenElse.parse_ifthenelse p) sl sl') (ensures LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload' s b sl == LowParse.Low.IfThenElse.gaccessor_ifthenelse_payload' s b sl')
{ "end_col": 54, "end_line": 243, "start_col": 2, "start_line": 238 }
FStar.Pervasives.Lemma
val valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t
val valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)))) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)))) =
false
null
true
valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "lemma" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Base.Spec.valid_facts", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "Prims.bool", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Low.Base.Spec.contents", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.Base.Spec.get_valid_pos", "Prims.unit", "LowParse.Spec.IfThenElse.parse_ifthenelse_eq", "LowParse.Slice.bytes_of_slice_from", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Low.Base.Spec.valid", "Prims.squash", "Prims.l_and", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_synth", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))))
[]
LowParse.Low.IfThenElse.valid_ifthenelse_elim
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.IfThenElse.parse_ifthenelse_param -> h: FStar.Monotonic.HyperStack.mem -> sl: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (LowParse.Spec.IfThenElse.parse_ifthenelse p) h sl pos) (ensures LowParse.Low.Base.Spec.valid (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) h sl pos /\ (let t = LowParse.Low.Base.Spec.contents (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p ) h sl pos in let pos_after_t = LowParse.Low.Base.Spec.get_valid_pos (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) h sl pos in let b = Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t in LowParse.Low.Base.Spec.valid (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.IfThenElse.parse_ifthenelse p) h sl pos (Mkparse_ifthenelse_param?.parse_ifthenelse_synth p t (LowParse.Low.Base.Spec.contents (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t)) (LowParse.Low.Base.Spec.get_valid_pos (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t)))
{ "end_col": 75, "end_line": 76, "start_col": 2, "start_line": 70 }
FStar.Pervasives.Lemma
val valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos)
val valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)))) let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)))) =
false
null
true
valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos)
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "lemma" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Spec.IfThenElse.parse_ifthenelse_eq", "LowParse.Slice.bytes_of_slice_from", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "Prims.bool", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Low.Base.Spec.contents", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "Prims.l_and", "LowParse.Low.Base.Spec.valid", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_synth", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))) (ensures (valid p.parse_ifthenelse_tag_parser h sl pos /\ (let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t)) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t))))
[]
LowParse.Low.IfThenElse.valid_ifthenelse_intro
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.IfThenElse.parse_ifthenelse_param -> h: FStar.Monotonic.HyperStack.mem -> sl: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) h sl pos /\ (let t = LowParse.Low.Base.Spec.contents (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p ) h sl pos in let pos_after_t = LowParse.Low.Base.Spec.get_valid_pos (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) h sl pos in let b = Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t in LowParse.Low.Base.Spec.valid (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t)) (ensures LowParse.Low.Base.Spec.valid (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) h sl pos /\ (let t = LowParse.Low.Base.Spec.contents (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p ) h sl pos in let b = Mkparse_ifthenelse_param?.parse_ifthenelse_tag_cond p t in let pos_after_t = LowParse.Low.Base.Spec.get_valid_pos (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) h sl pos in LowParse.Low.Base.Spec.valid (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.IfThenElse.parse_ifthenelse p) h sl pos (Mkparse_ifthenelse_param?.parse_ifthenelse_synth p t (LowParse.Low.Base.Spec.contents (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t)) (LowParse.Low.Base.Spec.get_valid_pos (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b)) h sl pos_after_t)))
{ "end_col": 54, "end_line": 46, "start_col": 2, "start_line": 40 }
Prims.Tot
val gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) = fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0
val gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s)) =
false
null
false
fun input -> parse_ifthenelse_eq p input; if Some? (parse (parse_ifthenelse p) input) then parse_ifthenelse_parse_tag_payload s input; 0
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Spec.IfThenElse.serialize_ifthenelse_param", "LowParse.Bytes.bytes", "Prims.unit", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.IfThenElse.parse_ifthenelse", "LowParse.Spec.IfThenElse.parse_ifthenelse_parse_tag_payload", "Prims.bool", "LowParse.Spec.IfThenElse.parse_ifthenelse_eq", "Prims.nat", "LowParse.Low.Base.Spec.gaccessor'", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.IfThenElse.clens_ifthenelse_tag" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t inline_for_extraction let jump_ifthenelse (p: parse_ifthenelse_param) (vt: jumper p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (jumper (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (jumper (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_elim p h input) pos in let pos_after_t = vt input pos in let b = test input pos in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t let clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); } let gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p)
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_ifthenelse_tag' (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (gaccessor' (parse_ifthenelse p) p.parse_ifthenelse_tag_parser (clens_ifthenelse_tag s))
[]
LowParse.Low.IfThenElse.gaccessor_ifthenelse_tag'
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s: LowParse.Spec.IfThenElse.serialize_ifthenelse_param p -> LowParse.Low.Base.Spec.gaccessor' (LowParse.Spec.IfThenElse.parse_ifthenelse p) (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) (LowParse.Low.IfThenElse.clens_ifthenelse_tag s)
{ "end_col": 5, "end_line": 148, "start_col": 2, "start_line": 144 }
Prims.Tot
val validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (validator (parse_ifthenelse p))
[ { "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.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.IfThenElse", "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 } ]
false
let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b)))) : Tot (validator (parse_ifthenelse p)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b (* eta-expansion here *) then vp true input pos_after_t else vp false input pos_after_t
val validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (validator (parse_ifthenelse p)) let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (validator (parse_ifthenelse p)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = Classical.move_requires (valid_ifthenelse_intro p h input) (uint64_to_uint32 pos); Classical.move_requires (valid_ifthenelse_elim p h input) (uint64_to_uint32 pos) in let pos_after_t = vt input pos in if is_error pos_after_t then pos_after_t else let b = test input (uint64_to_uint32 pos) in if b then vp true input pos_after_t else vp false input pos_after_t
{ "checked_file": "LowParse.Low.IfThenElse.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.IfThenElse.fst.checked", "LowParse.Low.Combinators.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.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.IfThenElse.fst" }
[ "total" ]
[ "LowParse.Spec.IfThenElse.parse_ifthenelse_param", "LowParse.Low.Base.validator", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_parser", "LowParse.Low.IfThenElse.test_ifthenelse_tag", "Prims.bool", "Prims.__proj__Mkdtuple2__item___1", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_t", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_payload_parser", "FStar.Pervasives.dsnd", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t", "LowParse.Low.ErrorCode.is_error", "LowParse.Low.ErrorCode.uint64_to_uint32", "Prims.unit", "FStar.Classical.move_requires", "FStar.UInt32.t", "LowParse.Low.Base.Spec.valid", "LowParse.Spec.IfThenElse.parse_ifthenelse_kind", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_t", "LowParse.Spec.IfThenElse.parse_ifthenelse", "Prims.l_and", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_tag_cond", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.Spec.get_valid_pos", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.IfThenElse.__proj__Mkparse_ifthenelse_param__item__parse_ifthenelse_synth", "LowParse.Low.IfThenElse.valid_ifthenelse_elim", "LowParse.Low.IfThenElse.valid_ifthenelse_intro", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module LowParse.Low.IfThenElse include LowParse.Spec.IfThenElse include LowParse.Low.Combinators module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module B = LowStar.Buffer module Cast = FStar.Int.Cast module U64 = FStar.UInt64 let valid_ifthenelse_intro (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t ))) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos) let valid_ifthenelse_elim (p: parse_ifthenelse_param) (h: HS.mem) (#rrel #rel: _) (sl: slice rrel rel) (pos: U32.t) : Lemma (requires (valid (parse_ifthenelse p) h sl pos)) (ensures ( valid p.parse_ifthenelse_tag_parser h sl pos /\ ( let t = contents p.parse_ifthenelse_tag_parser h sl pos in let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t /\ valid_content_pos (parse_ifthenelse p) h sl pos (p.parse_ifthenelse_synth t (contents (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ) (get_valid_pos (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t) ))) = valid_facts (parse_ifthenelse p) h sl pos; parse_ifthenelse_eq p (bytes_of_slice_from h sl pos); valid_facts p.parse_ifthenelse_tag_parser h sl pos; let pos_after_t = get_valid_pos p.parse_ifthenelse_tag_parser h sl pos in let t = contents p.parse_ifthenelse_tag_parser h sl pos in let b = p.parse_ifthenelse_tag_cond t in valid_facts (dsnd (p.parse_ifthenelse_payload_parser b)) h sl pos_after_t inline_for_extraction type test_ifthenelse_tag (p: parse_ifthenelse_param) = (#rrel: _) -> (#rel: _) -> (input: slice rrel rel) -> (pos: U32.t) -> HST.Stack bool (requires (fun h -> valid p.parse_ifthenelse_tag_parser h input pos)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == p.parse_ifthenelse_tag_cond (contents p.parse_ifthenelse_tag_parser h input pos) )) inline_for_extraction let validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool) -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b))))
false
false
LowParse.Low.IfThenElse.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_ifthenelse (p: parse_ifthenelse_param) (vt: validator p.parse_ifthenelse_tag_parser) (test: test_ifthenelse_tag p) (vp: (b: bool -> Tot (validator (dsnd (p.parse_ifthenelse_payload_parser b))))) : Tot (validator (parse_ifthenelse p))
[]
LowParse.Low.IfThenElse.validate_ifthenelse
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.IfThenElse.parse_ifthenelse_param -> vt: LowParse.Low.Base.validator (Mkparse_ifthenelse_param?.parse_ifthenelse_tag_parser p) -> test: LowParse.Low.IfThenElse.test_ifthenelse_tag p -> vp: (b: Prims.bool -> LowParse.Low.Base.validator (FStar.Pervasives.dsnd (Mkparse_ifthenelse_param?.parse_ifthenelse_payload_parser p b))) -> LowParse.Low.Base.validator (LowParse.Spec.IfThenElse.parse_ifthenelse p)
{ "end_col": 35, "end_line": 111, "start_col": 2, "start_line": 98 }
Prims.Tot
val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let member #a #len x l = Seq.count x l > 0
val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool let member #a #len x l =
false
null
false
Seq.count x l > 0
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Prims.eqtype", "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.op_GreaterThan", "FStar.Seq.Properties.count", "Prims.bool" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool
[]
Lib.Sequence.member
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: a -> l: Lib.Sequence.lseq a len -> Prims.bool
{ "end_col": 42, "end_line": 37, "start_col": 25, "start_line": 37 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs}
let generate_blocks_simple_a (a: Type) (bs: size_nat) (max: nat) (i: nat{i <= max}) =
false
null
false
s: seq a {length s == i * bs}
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val generate_blocks_simple_a : a: Type0 -> bs: Lib.IntTypes.size_nat -> max: Prims.nat -> i: Prims.nat{i <= max} -> Type0
[]
Lib.Sequence.generate_blocks_simple_a
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Type0 -> bs: Lib.IntTypes.size_nat -> max: Prims.nat -> i: Prims.nat{i <= max} -> Type0
{ "end_col": 109, "end_line": 210, "start_col": 82, "start_line": 210 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i]
let map_inner (#a #b: Type) (#len: size_nat) (f: (a -> Tot b)) (s: lseq a len) (i: size_nat{i < len}) =
false
null
false
f s.[ i ]
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.op_String_Access" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val map_inner : f: (_: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
[]
Lib.Sequence.map_inner
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (_: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
{ "end_col": 9, "end_line": 107, "start_col": 2, "start_line": 107 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
let generate_blocks_a (t: Type) (blocklen: size_nat) (max: nat) (a: (i: nat{i <= max} -> Type)) (i: nat{i <= max}) =
false
null
false
a i & s: seq t {length s == i * blocklen}
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = ()
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val generate_blocks_a : t: Type0 -> blocklen: Lib.IntTypes.size_nat -> max: Prims.nat -> a: (i: Prims.nat{i <= max} -> Type) -> i: Prims.nat{i <= max} -> Type
[]
Lib.Sequence.generate_blocks_a
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Type0 -> blocklen: Lib.IntTypes.size_nat -> max: Prims.nat -> a: (i: Prims.nat{i <= max} -> Type) -> i: Prims.nat{i <= max} -> Type
{ "end_col": 150, "end_line": 198, "start_col": 111, "start_line": 198 }
Prims.Tot
val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let for_all #a #len f x = Seq.for_all f x
val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool let for_all #a #len f x =
false
null
false
Seq.for_all f x
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.bool", "Lib.Sequence.lseq", "FStar.Seq.Properties.for_all" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool
[]
Lib.Sequence.for_all
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (_: a -> Prims.bool) -> x: Lib.Sequence.lseq a len -> Prims.bool
{ "end_col": 41, "end_line": 123, "start_col": 26, "start_line": 123 }
Prims.Tot
val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0 let equal #a #len s1 s2 =
false
null
false
forall (i: size_nat{i < len}). {:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.l_Forall", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val equal (#a:Type) (#len:size_nat) (s1:lseq a len) (s2:lseq a len) : Type0
[]
Lib.Sequence.equal
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq a len -> Type0
{ "end_col": 93, "end_line": 23, "start_col": 2, "start_line": 23 }
Prims.Tot
val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let index #a #len s n = Seq.index s n
val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i}) let index #a #len s n =
false
null
false
Seq.index s n
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.index", "Prims.eq2", "Lib.Sequence.to_seq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'"
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val index: #a:Type -> #len:size_nat -> s:lseq a len -> i:size_nat{i < len} -> Tot (r:a{r == Seq.index (to_seq s) i})
[]
Lib.Sequence.index
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> r: a{r == FStar.Seq.Base.index (Lib.Sequence.to_seq s) i}
{ "end_col": 37, "end_line": 9, "start_col": 24, "start_line": 9 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i]
let mapi_inner (#a #b: Type) (#len: size_nat) (f: (i: nat{i < len} -> a -> b)) (s: lseq a len) (i: size_nat{i < len}) =
false
null
false
f i s.[ i ]
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.op_String_Access" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mapi_inner : f: (i: Prims.nat{i < len} -> _: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
[]
Lib.Sequence.mapi_inner
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (i: Prims.nat{i < len} -> _: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
{ "end_col": 11, "end_line": 99, "start_col": 2, "start_line": 99 }
FStar.Pervasives.Lemma
val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)]
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2
val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)] let eq_elim #a #len s1 s2 =
false
null
true
assert (forall (i: nat{i < len}). {:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "FStar.Seq.Base.lemma_eq_elim", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eq_elim: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires equal s1 s2) (ensures s1 == s2) [SMTPat (equal s1 s2)]
[]
Lib.Sequence.eq_elim
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq a len -> FStar.Pervasives.Lemma (requires Lib.Sequence.equal s1 s2) (ensures s1 == s2) [SMTPat (Lib.Sequence.equal s1 s2)]
{ "end_col": 28, "end_line": 33, "start_col": 2, "start_line": 31 }
Prims.Tot
val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)}) let concat #a #len0 #len1 s0 s1 =
false
null
false
Seq.append s0 s1
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "FStar.Seq.Base.append", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val concat: #a:Type -> #len0:size_nat -> #len1:size_nat{len0 + len1 <= max_size_t} -> s0:lseq a len0 -> s1:lseq a len1 -> Tot (s2:lseq a (len0 + len1){to_seq s2 == Seq.append (to_seq s0) (to_seq s1)})
[]
Lib.Sequence.concat
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Lib.Sequence.lseq a len0 -> s1: Lib.Sequence.lseq a len1 -> s2: Lib.Sequence.lseq a (len0 + len1) { Lib.Sequence.to_seq s2 == FStar.Seq.Base.append (Lib.Sequence.to_seq s0) (Lib.Sequence.to_seq s1) }
{ "end_col": 50, "end_line": 13, "start_col": 34, "start_line": 13 }
FStar.Pervasives.Lemma
val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)]
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i
val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)] let of_list_index #a l i =
false
null
true
Seq.lemma_seq_of_list_index #a l i
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Lib.IntTypes.max_size_t", "Prims.nat", "Prims.op_LessThan", "FStar.Seq.Properties.lemma_seq_of_list_index", "Prims.unit" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val of_list_index: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> i:nat{i < List.Tot.length l} -> Lemma (index (of_list l) i == List.Tot.index l i) [SMTPat (index (of_list l) i)]
[]
Lib.Sequence.of_list_index
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Prims.list a {FStar.List.Tot.Base.length l <= Lib.IntTypes.max_size_t} -> i: Prims.nat{i < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures Lib.Sequence.index (Lib.Sequence.of_list l) i == FStar.List.Tot.Base.index l i) [SMTPat (Lib.Sequence.index (Lib.Sequence.of_list l) i)]
{ "end_col": 36, "end_line": 20, "start_col": 2, "start_line": 20 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k
let createi_a (a: Type) (len: size_nat) (init: (i: nat{i < len} -> a)) (k: nat{k <= len}) =
false
null
false
lseq a k
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val createi_a : a: Type0 -> len: Lib.IntTypes.size_nat -> init: (i: Prims.nat{i < len} -> a) -> k: Prims.nat{k <= len} -> Type0
[]
Lib.Sequence.createi_a
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Type0 -> len: Lib.IntTypes.size_nat -> init: (i: Prims.nat{i < len} -> a) -> k: Prims.nat{k <= len} -> Type0
{ "end_col": 10, "end_line": 71, "start_col": 2, "start_line": 71 }
Prims.Tot
val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r
val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool let for_all2 #a #b #len f x y =
false
null
false
let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.bool", "Lib.Sequence.lseq", "FStar.Seq.Properties.for_all", "Prims.op_Equality", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Lib.Sequence.index", "Lib.Sequence.map2" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val for_all2:#a:Type -> #b:Type -> #len:size_nat -> (a -> b -> Tot bool) -> s1:lseq a len -> s2:lseq b len -> Tot bool
[]
Lib.Sequence.for_all2
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (_: a -> _: b -> Prims.bool) -> s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq b len -> Prims.bool
{ "end_col": 37, "end_line": 127, "start_col": 31, "start_line": 125 }
Prims.Tot
val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let of_list #a l = Seq.seq_of_list #a l
val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l}) let of_list #a l =
false
null
false
Seq.seq_of_list #a l
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Prims.list", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Lib.IntTypes.max_size_t", "FStar.Seq.Properties.seq_of_list", "Lib.Sequence.lseq", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val of_list: #a:Type -> l:list a{List.Tot.length l <= max_size_t} -> Tot (s:lseq a (List.Tot.length l){to_seq s == Seq.seq_of_list l})
[]
Lib.Sequence.of_list
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Prims.list a {FStar.List.Tot.Base.length l <= Lib.IntTypes.max_size_t} -> s: Lib.Sequence.lseq a (FStar.List.Tot.Base.length l) {Lib.Sequence.to_seq s == FStar.Seq.Properties.seq_of_list l}
{ "end_col": 39, "end_line": 17, "start_col": 19, "start_line": 17 }
Prims.Tot
val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let to_list #a s = Seq.seq_to_list s
val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s}) let to_list #a s =
false
null
false
Seq.seq_to_list s
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.seq", "FStar.Seq.Properties.seq_to_list", "Prims.list", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.List.Tot.Base.length", "Lib.Sequence.length", "Prims.eq2" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == Seq.seq_to_list s})
[]
Lib.Sequence.to_list
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Lib.Sequence.seq a -> l: Prims.list a { FStar.List.Tot.Base.length l = Lib.Sequence.length s /\ l == FStar.Seq.Properties.seq_to_list s }
{ "end_col": 36, "end_line": 15, "start_col": 19, "start_line": 15 }
Prims.Tot
val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s)
val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])}) let mapi #a #b #len f s =
false
null
false
createi #b len (mapi_inner #a #b #len f s)
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.createi", "Lib.Sequence.mapi_inner", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Lib.Sequence.index", "Lib.Sequence.op_String_Access" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i]
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mapi:#a:Type -> #b:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> Tot b) -> s1:lseq a len -> Tot (s2:lseq b len{(forall (i:nat). {:pattern (index s2 i)} i < len ==> index s2 i == f i s1.[i])})
[]
Lib.Sequence.mapi
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (i: Prims.nat{i < len} -> _: a -> b) -> s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq b len { forall (i: Prims.nat). {:pattern Lib.Sequence.index s2 i} i < len ==> Lib.Sequence.index s2 i == f i s1.[ i ] }
{ "end_col": 44, "end_line": 102, "start_col": 2, "start_line": 102 }
FStar.Pervasives.Lemma
val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)]
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)] let eq_intro #a #len s1 s2 =
false
null
true
assert (forall (i: nat{i < len}). {:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2)
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "FStar.Seq.Base.lemma_eq_intro", "Lib.Sequence.to_seq", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eq_intro: #a:Type -> #len:size_nat -> s1:lseq a len -> s2:lseq a len -> Lemma (requires forall i. {:pattern index s1 i; index s2 i} index s1 i == index s2 i) (ensures equal s1 s2) [SMTPat (equal s1 s2)]
[]
Lib.Sequence.eq_intro
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq a len -> FStar.Pervasives.Lemma (requires forall (i: Lib.IntTypes.size_nat{i < len /\ i < len}). {:pattern Lib.Sequence.index s1 i; Lib.Sequence.index s2 i} Lib.Sequence.index s1 i == Lib.Sequence.index s2 i) (ensures Lib.Sequence.equal s1 s2) [SMTPat (Lib.Sequence.equal s1 s2)]
{ "end_col": 47, "end_line": 28, "start_col": 2, "start_line": 26 }
FStar.Pervasives.Lemma
val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_interval_lt b n i j = div_interval b n i; div_interval b n j
val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b) let mod_interval_lt b n i j =
false
null
true
div_interval b n i; div_interval b n j
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.int", "Lib.Sequence.div_interval", "Prims.unit" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mod_interval_lt: b:pos -> n:int -> i:int -> j:int -> Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b)
[]
Lib.Sequence.mod_interval_lt
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Prims.pos -> n: Prims.int -> i: Prims.int -> j: Prims.int -> FStar.Pervasives.Lemma (requires n * b <= i /\ i < j /\ j < (n + 1) * b) (ensures i % b < j % b)
{ "end_col": 20, "end_line": 233, "start_col": 2, "start_line": 232 }
Prims.Tot
val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_sub #a s start n = Seq.slice #a s start (start + n)
val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n =
false
null
false
Seq.slice #a s start (start + n)
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.Sequence.length", "FStar.Seq.Base.slice", "Prims.l_and", "Prims.eq2", "Prims.l_Forall", "Prims.op_LessThan", "FStar.Seq.Base.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))}
[]
Lib.Sequence.seq_sub
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s1: Lib.Sequence.seq a -> start: Prims.nat -> n: Prims.nat{start + n <= Lib.Sequence.length s1} -> s2: Lib.Sequence.seq a { Lib.Sequence.length s2 == n /\ (forall (k: Prims.nat{k < n}). {:pattern FStar.Seq.Base.index s2 k} FStar.Seq.Base.index s2 k == FStar.Seq.Base.index s1 (start + k)) }
{ "end_col": 34, "end_line": 138, "start_col": 2, "start_line": 138 }
Prims.Tot
val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i])
val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])}) let map2i #a #b #c #len f s1 s2 =
false
null
false
createi #c len (fun i -> f i s1.[ i ] s2.[ i ])
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.createi", "Lib.Sequence.op_String_Access", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Lib.Sequence.index" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val map2i:#a:Type -> #b:Type -> #c:Type -> #len:size_nat -> f:(i:nat{i < len} -> a -> b -> Tot c) -> s1:lseq a len -> s2:lseq b len -> Tot (s3:lseq c len{(forall (i:nat). {:pattern (index s3 i)} i < len ==> index s3 i == f i s1.[i] s2.[i])})
[]
Lib.Sequence.map2i
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (i: Prims.nat{i < len} -> _: a -> _: b -> c) -> s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq b len -> s3: Lib.Sequence.lseq c len { forall (i: Prims.nat). {:pattern Lib.Sequence.index s3 i} i < len ==> Lib.Sequence.index s3 i == f i s1.[ i ] s2.[ i ] }
{ "end_col": 45, "end_line": 113, "start_col": 2, "start_line": 113 }
Prims.Tot
val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty
val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize}) let generate_blocks_simple #a bs max nb f =
false
null
false
repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.LoopCombinators.repeat_gen", "Lib.Sequence.generate_blocks_simple_a", "Lib.Sequence.generate_blocks_simple_f", "FStar.Seq.Base.empty", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val generate_blocks_simple: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> f:(i:nat{i < max} -> lseq a blocksize) -> Tot (s:seq a{length s == n * blocksize})
[]
Lib.Sequence.generate_blocks_simple
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> max: Prims.nat -> n: Prims.nat{n <= max} -> f: (i: Prims.nat{i < max} -> Lib.Sequence.lseq a blocksize) -> s: Lib.Sequence.seq a {Lib.Sequence.length s == n * blocksize}
{ "end_col": 51, "end_line": 224, "start_col": 1, "start_line": 223 }
Prims.Tot
val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o
val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x =
false
null
false
let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.Sequence.length", "Prims.eq2", "Prims.unit", "FStar.Seq.Base.lemma_eq_intro", "FStar.Seq.Base.slice", "FStar.Seq.Base.seq", "FStar.Seq.Base.append", "Prims.l_and", "Prims.l_or", "Prims.l_Forall", "Prims.op_LessThan", "FStar.Seq.Base.index", "Lib.Sequence.seq_sub" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}).
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)}
[]
Lib.Sequence.seq_update_sub
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Lib.Sequence.seq a -> start: Prims.nat -> n: Prims.nat{start + n <= Lib.Sequence.length i} -> x: Lib.Sequence.seq a {Lib.Sequence.length x == n} -> o: Lib.Sequence.seq a { Lib.Sequence.length o == Lib.Sequence.length i /\ Lib.Sequence.seq_sub o start n == x /\ (forall (k: Prims.nat{0 <= k /\ k < start \/ start + n <= k /\ k < Lib.Sequence.length i}). {:pattern FStar.Seq.Base.index o k} FStar.Seq.Base.index o k == FStar.Seq.Base.index i k) }
{ "end_col": 3, "end_line": 156, "start_col": 35, "start_line": 150 }
Prims.Tot
val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc
val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c let repeat_blocks #a #b #c bs inp f l init =
false
null
false
let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Lib.Sequence.lseq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.l_and", "Prims.eq2", "Lib.Sequence.length", "Prims.l_Forall", "FStar.Seq.Base.index", "Prims.op_Addition", "Prims.op_Multiply", "Lib.Sequence.seq_sub", "FStar.Mul.op_Star", "Lib.LoopCombinators.repeati", "Lib.Sequence.repeat_blocks_f", "Prims.int", "Prims.op_Modulus", "Prims.op_Division" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> init:b -> Tot c
[]
Lib.Sequence.repeat_blocks
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a -> f: (_: Lib.Sequence.lseq a blocksize -> _: b -> b) -> l: (len: Prims.nat{len < blocksize} -> s: Lib.Sequence.lseq a len -> _: b -> c) -> init: b -> c
{ "end_col": 16, "end_line": 187, "start_col": 44, "start_line": 181 }
FStar.Pervasives.Lemma
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_prop n a b = Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n) let mod_prop n a b =
false
null
true
Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Math.Lemmas.lemma_mod_sub", "Prims.unit", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Subtraction" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); } let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty let lemma_map_blocks_multi #a bs max nb inp f = () private val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n)
[]
Lib.Sequence.mod_prop
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.pos -> a: Prims.nat -> b: Prims.nat{a * n <= b /\ b < (a + 1) * n} -> FStar.Pervasives.Lemma (ensures b - a * n == b % n)
{ "end_col": 33, "end_line": 267, "start_col": 2, "start_line": 266 }
Prims.Tot
val createi_step (a: Type) (len: size_nat) (init: (i: nat{i < len} -> a)) (i: nat{i < len}) (si: createi_a a len init i) : r: createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i)
val createi_step (a: Type) (len: size_nat) (init: (i: nat{i < len} -> a)) (i: nat{i < len}) (si: createi_a a len init i) : r: createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} let createi_step (a: Type) (len: size_nat) (init: (i: nat{i < len} -> a)) (i: nat{i < len}) (si: createi_a a len init i) : r: createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} =
false
null
false
assert (createi_pred a len init i si ==> (forall (j: nat). j < i ==> index si j == init j)); Seq.snoc si (init i)
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.createi_a", "FStar.Seq.Properties.snoc", "Prims.unit", "Prims._assert", "Prims.l_imp", "Lib.Sequence.createi_pred", "Prims.l_Forall", "Prims.eq2", "Lib.Sequence.index", "Prims.op_Addition" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val createi_step (a: Type) (len: size_nat) (init: (i: nat{i < len} -> a)) (i: nat{i < len}) (si: createi_a a len init i) : r: createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r}
[]
Lib.Sequence.createi_step
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Type0 -> len: Lib.IntTypes.size_nat -> init: (i: Prims.nat{i < len} -> a) -> i: Prims.nat{i < len} -> si: Lib.Sequence.createi_a a len init i -> r: Lib.Sequence.createi_a a len init (i + 1) {Lib.Sequence.createi_pred a len init i si ==> Lib.Sequence.createi_pred a len init (i + 1) r}
{ "end_col": 22, "end_line": 83, "start_col": 2, "start_line": 82 }
FStar.Pervasives.Lemma
val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b
val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n) let div_interval b n i =
false
null
true
Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.int", "FStar.Math.Lemmas.cancel_mul_div", "Prims.unit", "FStar.Math.Lemmas.lemma_div_le", "FStar.Mul.op_Star" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div_interval: b:pos -> n:int -> i:int -> Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n)
[]
Lib.Sequence.div_interval
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Prims.pos -> n: Prims.int -> i: Prims.int -> FStar.Pervasives.Lemma (requires n * b <= i /\ i < (n + 1) * b) (ensures i / b = n)
{ "end_col": 32, "end_line": 229, "start_col": 2, "start_line": 228 }
Prims.Tot
val create4: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> lseq a 4
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create4 #a x0 x1 x2 x3 = let l = [x0; x1; x2; x3] in assert_norm (List.Tot.length l = 4); createL l
val create4: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> lseq a 4 let create4 #a x0 x1 x2 x3 =
false
null
false
let l = [x0; x1; x2; x3] in assert_norm (List.Tot.length l = 4); createL l
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.createL", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "Prims.Nil", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); } let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty let lemma_map_blocks_multi #a bs max nb inp f = () private val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n) let mod_prop n a b = Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a #push-options "--z3rlimit 200" let rec index_map_blocks_multi #a bs max n inp f i = let map_blocks_a = map_blocks_a a bs max in let map_blocks_f = map_blocks_f #a bs max inp f in let acc0 = Seq.empty #a in let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1); let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in //assert (s1 == map_blocks_f (n-1) s); let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in //assert (s1 == Seq.append s s'); if i < (n-1)*bs then begin Seq.lemma_index_app1 s s' i; index_map_blocks_multi #a bs max (n-1) inp f i end else begin Seq.lemma_index_app2 s s' i; mod_prop bs (n-1) i end let map_blocks #a blocksize inp f g = let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in let bs = map_blocks_multi #a blocksize nb nb blocks f in if (rem > 0) then Seq.append bs (g nb rem last) else bs let lemma_map_blocks #a blocksize inp f g = () let index_map_blocks #a bs inp f g i = let len = length inp in let nb = len / bs in let rem = len % bs in let blocks = Seq.slice inp 0 (nb * bs) in if rem > 0 then begin let s1 = map_blocks_multi #a bs nb nb blocks f in let last = Seq.slice inp (nb * bs) len in calc (==) { length last; == { Seq.lemma_len_slice inp (nb * bs) len } len - nb * bs; == {mod_prop bs nb len} len % bs; == { } rem; }; let s2 = g nb rem last in assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2)); if i < nb * bs then begin div_mul_lt bs i nb; Seq.lemma_index_app1 s1 s2 i; index_map_blocks_multi bs nb nb blocks f i end else begin Seq.lemma_index_app2 s1 s2 i; mod_prop bs nb i end end else index_map_blocks_multi #a bs nb nb blocks f i let eq_generate_blocks0 #t len n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n 0 a f acc0 == repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 let unfold_generate_blocks #t len n a f acc0 i = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n (i+1) a f acc0 == repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i let rec index_generate_blocks #t len max n f i = assert (0 < n); let a_spec (i:nat{i <= max}) = unit in let _,s = generate_blocks #t len max (n-1) a_spec f () in let _,s' = f (n-1) () in let _,s1 = generate_blocks #t len max n a_spec f () in unfold_generate_blocks #t len max a_spec f () (n-1); Seq.Properties.lemma_split s1 (n * len - len); Seq.Properties.lemma_split (Seq.append s s') (n * len - len); Seq.lemma_eq_intro s1 (Seq.append s s'); if i < (n-1) * len then begin Seq.lemma_index_app1 s s' i; index_generate_blocks len max (n-1) f i end else begin Seq.lemma_index_app2 s s' i; mod_prop len (n-1) i end #push-options "--using_facts_from '+FStar.UInt.pow2_values'" let create2 #a x0 x1 = let l = [x0; x1] in assert_norm (List.Tot.length l = 2); createL l let create2_lemma #a x0 x1 = Seq.elim_of_list [x0; x1]
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create4: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> lseq a 4
[]
Lib.Sequence.create4
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: a -> x1: a -> x2: a -> x3: a -> Lib.Sequence.lseq a 4
{ "end_col": 11, "end_line": 382, "start_col": 28, "start_line": 379 }
Prims.Tot
val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init
val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b let repeat_blocks_multi #a #b bs inp f init =
false
null
false
let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Lib.Sequence.length", "Lib.Sequence.lseq", "Lib.LoopCombinators.repeati", "Lib.Sequence.repeat_blocks_f", "Prims.op_Division", "Prims.nat" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = ()
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_blocks_multi: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> init:b -> Tot b
[]
Lib.Sequence.repeat_blocks_multi
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp % blocksize = 0} -> f: (_: Lib.Sequence.lseq a blocksize -> _: b -> b) -> init: b -> b
{ "end_col": 47, "end_line": 194, "start_col": 45, "start_line": 191 }
Prims.Tot
val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty
val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize}) let map_blocks_multi #a bs max nb inp f =
false
null
false
repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.LoopCombinators.repeat_gen", "Lib.Sequence.map_blocks_a", "Lib.Sequence.map_blocks_f", "FStar.Seq.Base.empty" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); }
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val map_blocks_multi: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Tot (out:seq a {length out == n * blocksize})
[]
Lib.Sequence.map_blocks_multi
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> max: Prims.nat -> n: Prims.nat{n <= max} -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp == max * blocksize} -> f: (i: Prims.nat{i < max} -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize) -> out: Lib.Sequence.seq a {Lib.Sequence.length out == n * blocksize}
{ "end_col": 44, "end_line": 258, "start_col": 2, "start_line": 257 }
FStar.Pervasives.Lemma
val create2_lemma: #a:Type -> x0:a -> x1:a -> Lemma (let s = create2 x0 x1 in s.[0] == x0 /\ s.[1] == x1) [SMTPat (create2 #a x0 x1)]
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create2_lemma #a x0 x1 = Seq.elim_of_list [x0; x1]
val create2_lemma: #a:Type -> x0:a -> x1:a -> Lemma (let s = create2 x0 x1 in s.[0] == x0 /\ s.[1] == x1) [SMTPat (create2 #a x0 x1)] let create2_lemma #a x0 x1 =
false
null
true
Seq.elim_of_list [x0; x1]
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "FStar.Seq.Properties.elim_of_list", "Prims.Cons", "Prims.Nil", "Prims.unit" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); } let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty let lemma_map_blocks_multi #a bs max nb inp f = () private val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n) let mod_prop n a b = Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a #push-options "--z3rlimit 200" let rec index_map_blocks_multi #a bs max n inp f i = let map_blocks_a = map_blocks_a a bs max in let map_blocks_f = map_blocks_f #a bs max inp f in let acc0 = Seq.empty #a in let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1); let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in //assert (s1 == map_blocks_f (n-1) s); let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in //assert (s1 == Seq.append s s'); if i < (n-1)*bs then begin Seq.lemma_index_app1 s s' i; index_map_blocks_multi #a bs max (n-1) inp f i end else begin Seq.lemma_index_app2 s s' i; mod_prop bs (n-1) i end let map_blocks #a blocksize inp f g = let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in let bs = map_blocks_multi #a blocksize nb nb blocks f in if (rem > 0) then Seq.append bs (g nb rem last) else bs let lemma_map_blocks #a blocksize inp f g = () let index_map_blocks #a bs inp f g i = let len = length inp in let nb = len / bs in let rem = len % bs in let blocks = Seq.slice inp 0 (nb * bs) in if rem > 0 then begin let s1 = map_blocks_multi #a bs nb nb blocks f in let last = Seq.slice inp (nb * bs) len in calc (==) { length last; == { Seq.lemma_len_slice inp (nb * bs) len } len - nb * bs; == {mod_prop bs nb len} len % bs; == { } rem; }; let s2 = g nb rem last in assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2)); if i < nb * bs then begin div_mul_lt bs i nb; Seq.lemma_index_app1 s1 s2 i; index_map_blocks_multi bs nb nb blocks f i end else begin Seq.lemma_index_app2 s1 s2 i; mod_prop bs nb i end end else index_map_blocks_multi #a bs nb nb blocks f i let eq_generate_blocks0 #t len n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n 0 a f acc0 == repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 let unfold_generate_blocks #t len n a f acc0 i = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n (i+1) a f acc0 == repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i let rec index_generate_blocks #t len max n f i = assert (0 < n); let a_spec (i:nat{i <= max}) = unit in let _,s = generate_blocks #t len max (n-1) a_spec f () in let _,s' = f (n-1) () in let _,s1 = generate_blocks #t len max n a_spec f () in unfold_generate_blocks #t len max a_spec f () (n-1); Seq.Properties.lemma_split s1 (n * len - len); Seq.Properties.lemma_split (Seq.append s s') (n * len - len); Seq.lemma_eq_intro s1 (Seq.append s s'); if i < (n-1) * len then begin Seq.lemma_index_app1 s s' i; index_generate_blocks len max (n-1) f i end else begin Seq.lemma_index_app2 s s' i; mod_prop len (n-1) i end #push-options "--using_facts_from '+FStar.UInt.pow2_values'" let create2 #a x0 x1 = let l = [x0; x1] in assert_norm (List.Tot.length l = 2); createL l
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create2_lemma: #a:Type -> x0:a -> x1:a -> Lemma (let s = create2 x0 x1 in s.[0] == x0 /\ s.[1] == x1) [SMTPat (create2 #a x0 x1)]
[]
Lib.Sequence.create2_lemma
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: a -> x1: a -> FStar.Pervasives.Lemma (ensures (let s = Lib.Sequence.create2 x0 x1 in s.[ 0 ] == x0 /\ s.[ 1 ] == x1)) [SMTPat (Lib.Sequence.create2 x0 x1)]
{ "end_col": 27, "end_line": 377, "start_col": 2, "start_line": 377 }
Prims.Tot
val generate_blocks_inner (t: Type) (blocklen: size_nat) (max: nat) (a: (i: nat{i <= max} -> Type)) (f: (i: nat{i < max} -> a i -> a (i + 1) & s: seq t {length s == blocklen})) (i: nat{i < max}) (acc: generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o'
val generate_blocks_inner (t: Type) (blocklen: size_nat) (max: nat) (a: (i: nat{i <= max} -> Type)) (f: (i: nat{i < max} -> a i -> a (i + 1) & s: seq t {length s == blocklen})) (i: nat{i < max}) (acc: generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) let generate_blocks_inner (t: Type) (blocklen: size_nat) (max: nat) (a: (i: nat{i <= max} -> Type)) (f: (i: nat{i < max} -> a i -> a (i + 1) & s: seq t {length s == blocklen})) (i: nat{i < max}) (acc: generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) =
false
null
false
let acc, o = acc in let acc', block = f i acc in let o':s: seq t {length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o'
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Pervasives.Native.tuple2", "Prims.op_Addition", "Lib.Sequence.seq", "Prims.eq2", "Lib.Sequence.length", "Lib.Sequence.generate_blocks_a", "Prims.int", "FStar.Mul.op_Star", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Multiply", "FStar.Seq.Base.append" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen}
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val generate_blocks_inner (t: Type) (blocklen: size_nat) (max: nat) (a: (i: nat{i <= max} -> Type)) (f: (i: nat{i < max} -> a i -> a (i + 1) & s: seq t {length s == blocklen})) (i: nat{i < max}) (acc: generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1)
[]
Lib.Sequence.generate_blocks_inner
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Type0 -> blocklen: Lib.IntTypes.size_nat -> max: Prims.nat -> a: (i: Prims.nat{i <= max} -> Type) -> f: (i: Prims.nat{i < max} -> _: a i -> a (i + 1) * s: Lib.Sequence.seq t {Lib.Sequence.length s == blocklen}) -> i: Prims.nat{i < max} -> acc: Lib.Sequence.generate_blocks_a t blocklen max a i -> Lib.Sequence.generate_blocks_a t blocklen max a (i + 1)
{ "end_col": 12, "end_line": 204, "start_col": 274, "start_line": 200 }
Prims.Tot
val create8: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a -> lseq a 8
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create8 #a x0 x1 x2 x3 x4 x5 x6 x7 = let l = [x0; x1; x2; x3; x4; x5; x6; x7] in assert_norm (List.Tot.length l = 8); createL l
val create8: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a -> lseq a 8 let create8 #a x0 x1 x2 x3 x4 x5 x6 x7 =
false
null
false
let l = [x0; x1; x2; x3; x4; x5; x6; x7] in assert_norm (List.Tot.length l = 8); createL l
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.createL", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "Prims.Nil", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); } let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty let lemma_map_blocks_multi #a bs max nb inp f = () private val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n) let mod_prop n a b = Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a #push-options "--z3rlimit 200" let rec index_map_blocks_multi #a bs max n inp f i = let map_blocks_a = map_blocks_a a bs max in let map_blocks_f = map_blocks_f #a bs max inp f in let acc0 = Seq.empty #a in let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1); let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in //assert (s1 == map_blocks_f (n-1) s); let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in //assert (s1 == Seq.append s s'); if i < (n-1)*bs then begin Seq.lemma_index_app1 s s' i; index_map_blocks_multi #a bs max (n-1) inp f i end else begin Seq.lemma_index_app2 s s' i; mod_prop bs (n-1) i end let map_blocks #a blocksize inp f g = let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in let bs = map_blocks_multi #a blocksize nb nb blocks f in if (rem > 0) then Seq.append bs (g nb rem last) else bs let lemma_map_blocks #a blocksize inp f g = () let index_map_blocks #a bs inp f g i = let len = length inp in let nb = len / bs in let rem = len % bs in let blocks = Seq.slice inp 0 (nb * bs) in if rem > 0 then begin let s1 = map_blocks_multi #a bs nb nb blocks f in let last = Seq.slice inp (nb * bs) len in calc (==) { length last; == { Seq.lemma_len_slice inp (nb * bs) len } len - nb * bs; == {mod_prop bs nb len} len % bs; == { } rem; }; let s2 = g nb rem last in assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2)); if i < nb * bs then begin div_mul_lt bs i nb; Seq.lemma_index_app1 s1 s2 i; index_map_blocks_multi bs nb nb blocks f i end else begin Seq.lemma_index_app2 s1 s2 i; mod_prop bs nb i end end else index_map_blocks_multi #a bs nb nb blocks f i let eq_generate_blocks0 #t len n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n 0 a f acc0 == repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 let unfold_generate_blocks #t len n a f acc0 i = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n (i+1) a f acc0 == repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i let rec index_generate_blocks #t len max n f i = assert (0 < n); let a_spec (i:nat{i <= max}) = unit in let _,s = generate_blocks #t len max (n-1) a_spec f () in let _,s' = f (n-1) () in let _,s1 = generate_blocks #t len max n a_spec f () in unfold_generate_blocks #t len max a_spec f () (n-1); Seq.Properties.lemma_split s1 (n * len - len); Seq.Properties.lemma_split (Seq.append s s') (n * len - len); Seq.lemma_eq_intro s1 (Seq.append s s'); if i < (n-1) * len then begin Seq.lemma_index_app1 s s' i; index_generate_blocks len max (n-1) f i end else begin Seq.lemma_index_app2 s s' i; mod_prop len (n-1) i end #push-options "--using_facts_from '+FStar.UInt.pow2_values'" let create2 #a x0 x1 = let l = [x0; x1] in assert_norm (List.Tot.length l = 2); createL l let create2_lemma #a x0 x1 = Seq.elim_of_list [x0; x1] let create4 #a x0 x1 x2 x3 = let l = [x0; x1; x2; x3] in assert_norm (List.Tot.length l = 4); createL l let create4_lemma #a x0 x1 x2 x3 = Seq.elim_of_list [x0; x1; x2; x3]
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create8: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a -> lseq a 8
[]
Lib.Sequence.create8
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: a -> x1: a -> x2: a -> x3: a -> x4: a -> x5: a -> x6: a -> x7: a -> Lib.Sequence.lseq a 8
{ "end_col": 11, "end_line": 390, "start_col": 40, "start_line": 387 }
FStar.Pervasives.Lemma
val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d))
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); }
val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d)) let div_mul_l a b c d =
false
null
true
calc ( == ) { a / (c * d); ( == ) { () } a / (d * c); ( == ) { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; ( == ) { () } (b / d) / c; ( == ) { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); ( == ) { () } b / (c * d); }
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Prims.int", "Prims.pos", "FStar.Calc.calc_finish", "Prims.eq2", "Prims.op_Division", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.division_multiplication_lemma" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div_mul_l: a:int -> b:int -> c:pos -> d:pos -> Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d))
[]
Lib.Sequence.div_mul_l
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.int -> b: Prims.int -> c: Prims.pos -> d: Prims.pos -> FStar.Pervasives.Lemma (requires a / d = b / d) (ensures a / (c * d) = b / (c * d))
{ "end_col": 3, "end_line": 253, "start_col": 2, "start_line": 241 }
Prims.Tot
val create2: #a:Type -> x0:a -> x1:a -> lseq a 2
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create2 #a x0 x1 = let l = [x0; x1] in assert_norm (List.Tot.length l = 2); createL l
val create2: #a:Type -> x0:a -> x1:a -> lseq a 2 let create2 #a x0 x1 =
false
null
false
let l = [x0; x1] in assert_norm (List.Tot.length l = 2); createL l
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.createL", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "Prims.Nil", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); } let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty let lemma_map_blocks_multi #a bs max nb inp f = () private val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n) let mod_prop n a b = Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a #push-options "--z3rlimit 200" let rec index_map_blocks_multi #a bs max n inp f i = let map_blocks_a = map_blocks_a a bs max in let map_blocks_f = map_blocks_f #a bs max inp f in let acc0 = Seq.empty #a in let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1); let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in //assert (s1 == map_blocks_f (n-1) s); let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in //assert (s1 == Seq.append s s'); if i < (n-1)*bs then begin Seq.lemma_index_app1 s s' i; index_map_blocks_multi #a bs max (n-1) inp f i end else begin Seq.lemma_index_app2 s s' i; mod_prop bs (n-1) i end let map_blocks #a blocksize inp f g = let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in let bs = map_blocks_multi #a blocksize nb nb blocks f in if (rem > 0) then Seq.append bs (g nb rem last) else bs let lemma_map_blocks #a blocksize inp f g = () let index_map_blocks #a bs inp f g i = let len = length inp in let nb = len / bs in let rem = len % bs in let blocks = Seq.slice inp 0 (nb * bs) in if rem > 0 then begin let s1 = map_blocks_multi #a bs nb nb blocks f in let last = Seq.slice inp (nb * bs) len in calc (==) { length last; == { Seq.lemma_len_slice inp (nb * bs) len } len - nb * bs; == {mod_prop bs nb len} len % bs; == { } rem; }; let s2 = g nb rem last in assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2)); if i < nb * bs then begin div_mul_lt bs i nb; Seq.lemma_index_app1 s1 s2 i; index_map_blocks_multi bs nb nb blocks f i end else begin Seq.lemma_index_app2 s1 s2 i; mod_prop bs nb i end end else index_map_blocks_multi #a bs nb nb blocks f i let eq_generate_blocks0 #t len n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n 0 a f acc0 == repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 let unfold_generate_blocks #t len n a f acc0 i = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n (i+1) a f acc0 == repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i let rec index_generate_blocks #t len max n f i = assert (0 < n); let a_spec (i:nat{i <= max}) = unit in let _,s = generate_blocks #t len max (n-1) a_spec f () in let _,s' = f (n-1) () in let _,s1 = generate_blocks #t len max n a_spec f () in unfold_generate_blocks #t len max a_spec f () (n-1); Seq.Properties.lemma_split s1 (n * len - len); Seq.Properties.lemma_split (Seq.append s s') (n * len - len); Seq.lemma_eq_intro s1 (Seq.append s s'); if i < (n-1) * len then begin Seq.lemma_index_app1 s s' i; index_generate_blocks len max (n-1) f i end else begin Seq.lemma_index_app2 s s' i; mod_prop len (n-1) i end #push-options "--using_facts_from '+FStar.UInt.pow2_values'"
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create2: #a:Type -> x0:a -> x1:a -> lseq a 2
[]
Lib.Sequence.create2
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: a -> x1: a -> Lib.Sequence.lseq a 2
{ "end_col": 11, "end_line": 374, "start_col": 22, "start_line": 371 }
FStar.Pervasives.Lemma
val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s =
false
null
true
let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2)
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "lemma" ]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "FStar.Seq.Base.lemma_eq_intro", "Lib.Sequence.concat", "Prims.unit", "FStar.Seq.Properties.lemma_split", "Lib.Sequence.sub", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.append" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1)
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_concat3: #a:Type0 -> len0:size_nat -> s0:lseq a len0 -> len1:size_nat{len0 + len1 <= max_size_t} -> s1:lseq a len1 -> len2:size_nat{len0 + len1 + len2 <= max_size_t} -> s2:lseq a len2 -> s:lseq a (len0 + len1 + len2) -> Lemma (requires sub s 0 len0 == s0 /\ sub s len0 len1 == s1 /\ sub s (len0 + len1) len2 == s2) (ensures s == concat (concat s0 s1) s2)
[]
Lib.Sequence.lemma_concat3
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len0: Lib.IntTypes.size_nat -> s0: Lib.Sequence.lseq a len0 -> len1: Lib.IntTypes.size_nat{len0 + len1 <= Lib.IntTypes.max_size_t} -> s1: Lib.Sequence.lseq a len1 -> len2: Lib.IntTypes.size_nat{len0 + len1 + len2 <= Lib.IntTypes.max_size_t} -> s2: Lib.Sequence.lseq a len2 -> s: Lib.Sequence.lseq a (len0 + len1 + len2) -> FStar.Pervasives.Lemma (requires Lib.Sequence.sub s 0 len0 == s0 /\ Lib.Sequence.sub s len0 len1 == s1 /\ Lib.Sequence.sub s (len0 + len1) len2 == s2) (ensures s == Lib.Sequence.concat (Lib.Sequence.concat s0 s1) s2)
{ "end_col": 49, "end_line": 68, "start_col": 48, "start_line": 62 }
Prims.Tot
val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len})
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len}) let generate_blocks #t len max n a f acc0 =
false
null
false
let a0 = (acc0, (Seq.empty <: s: seq t {length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Pervasives.Native.tuple2", "Prims.op_Addition", "Lib.Sequence.seq", "Prims.eq2", "Lib.Sequence.length", "Lib.LoopCombinators.repeat_gen", "Lib.Sequence.generate_blocks_a", "Lib.Sequence.generate_blocks_inner", "Prims.int", "Prims.op_Multiply", "FStar.Pervasives.Native.Mktuple2", "FStar.Mul.op_Star", "FStar.Seq.Base.empty" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o'
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val generate_blocks: #t:Type0 -> len:size_nat -> max:nat -> n:nat{n <= max} -> a:(i:nat{i <= max} -> Type) -> f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == len}) -> init:a 0 -> Tot (a n & s:seq t{length s == n * len})
[]
Lib.Sequence.generate_blocks
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_nat -> max: Prims.nat -> n: Prims.nat{n <= max} -> a: (i: Prims.nat{i <= max} -> Type) -> f: (i: Prims.nat{i < max} -> _: a i -> a (i + 1) * s: Lib.Sequence.seq t {Lib.Sequence.length s == len}) -> init: a 0 -> a n * s: Lib.Sequence.seq t {Lib.Sequence.length s == n * len}
{ "end_col": 87, "end_line": 208, "start_col": 43, "start_line": 206 }
Prims.Tot
val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc
val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b let repeati_blocks #a #b bs inp f g init =
false
null
false
let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.Sequence.length", "Lib.Sequence.lseq", "Prims.eq2", "Prims.int", "Lib.IntTypes.size_nat", "Prims.op_Modulus", "Prims.l_and", "Prims.l_Forall", "FStar.Seq.Base.index", "Prims.op_Addition", "Prims.op_Multiply", "Lib.Sequence.seq_sub", "FStar.Mul.op_Star", "Lib.LoopCombinators.repeati", "Lib.Sequence.repeati_blocks_f" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeati_blocks: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> l:(i:nat{i == length inp / blocksize} -> len:size_nat{len == length inp % blocksize} -> s:lseq a len -> b -> b) -> init:b -> Tot b
[]
Lib.Sequence.repeati_blocks
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a -> f: ( i: Prims.nat{i < Lib.Sequence.length inp / blocksize} -> _: Lib.Sequence.lseq a blocksize -> _: b -> b) -> l: ( i: Prims.nat{i == Lib.Sequence.length inp / blocksize} -> len: Lib.IntTypes.size_nat{len == Lib.Sequence.length inp % blocksize} -> s: Lib.Sequence.lseq a len -> _: b -> b) -> init: b -> b
{ "end_col": 19, "end_line": 179, "start_col": 42, "start_line": 173 }
Prims.Tot
val create16: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a -> x8:a -> x9:a -> x10:a -> x11:a -> x12:a -> x13:a -> x14:a -> x15:a -> lseq a 16
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create16 #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 = let l = [x0; x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; x15] in assert_norm (List.Tot.length l = 16); createL l
val create16: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a -> x8:a -> x9:a -> x10:a -> x11:a -> x12:a -> x13:a -> x14:a -> x15:a -> lseq a 16 let create16 #a x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 =
false
null
false
let l = [x0; x1; x2; x3; x4; x5; x6; x7; x8; x9; x10; x11; x12; x13; x14; x15] in assert_norm (List.Tot.length l = 16); createL l
{ "checked_file": "Lib.Sequence.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Sequence.fst" }
[ "total" ]
[ "Lib.Sequence.createL", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "Prims.Nil", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators #set-options "--z3rlimit 30 --max_fuel 0 --max_ifuel 0 --using_facts_from '-* +Prims +FStar.Pervasives +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence'" let index #a #len s n = Seq.index s n let create #a len init = Seq.create #a len init let concat #a #len0 #len1 s0 s1 = Seq.append s0 s1 let to_list #a s = Seq.seq_to_list s let of_list #a l = Seq.seq_of_list #a l let of_list_index #a l i = Seq.lemma_seq_of_list_index #a l i let equal #a #len s1 s2 = forall (i:size_nat{i < len}).{:pattern (index s1 i); (index s2 i)} index s1 i == index s2 i let eq_intro #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_intro #a (to_seq s1) (to_seq s2) let eq_elim #a #len s1 s2 = assert (forall (i:nat{i < len}).{:pattern (Seq.index s1 i); (Seq.index s2 i)} index s1 i == index s2 i); Seq.lemma_eq_elim #a s1 s2 let upd #a #len s n x = Seq.upd #a s n x let member #a #len x l = Seq.count x l > 0 let sub #a #len s start n = Seq.slice #a s start (start + n) let update_sub #a #len s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o let lemma_update_sub #a #len dst start n src res = let res1 = update_sub dst start n src in Seq.lemma_split (sub res 0 (start + n)) start; Seq.lemma_split (sub res1 0 (start + n)) start; Seq.lemma_split res (start + n); Seq.lemma_split res1 (start + n); Seq.lemma_eq_intro res (update_sub dst start n src) let lemma_concat2 #a len0 s0 len1 s1 s = Seq.Properties.lemma_split s len0; Seq.Properties.lemma_split (concat s0 s1) len0; Seq.lemma_eq_intro s (concat s0 s1) let lemma_concat3 #a len0 s0 len1 s1 len2 s2 s = let s' = concat (concat s0 s1) s2 in Seq.Properties.lemma_split (sub s 0 (len0 + len1)) len0; Seq.Properties.lemma_split (sub s' 0 (len0 + len1)) len0; Seq.Properties.lemma_split s (len0 + len1); Seq.Properties.lemma_split s' (len0 + len1); Seq.lemma_eq_intro s (concat (concat s0 s1) s2) let createi_a (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) = lseq a k let createi_pred (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (k:nat{k <= len}) (s:createi_a a len init k) = forall (i:nat).{:pattern (index s i)} i < k ==> index s i == init i let createi_step (a:Type) (len:size_nat) (init:(i:nat{i < len} -> a)) (i:nat{i < len}) (si:createi_a a len init i) : r:createi_a a len init (i + 1) {createi_pred a len init i si ==> createi_pred a len init (i + 1) r} = assert (createi_pred a len init i si ==> (forall (j:nat). j < i ==> index si j == init j)); Seq.snoc si (init i) #push-options "--max_fuel 1 --using_facts_from '+Lib.LoopCombinators +FStar.List'" let createi #a len init_f = repeat_gen_inductive len (createi_a a len init_f) (createi_pred a len init_f) (createi_step a len init_f) (of_list []) #pop-options inline_for_extraction let mapi_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(i:nat{i < len} -> a -> b)) (s:lseq a len) (i:size_nat{i < len}) = f i s.[i] let mapi #a #b #len f s = createi #b len (mapi_inner #a #b #len f s) inline_for_extraction let map_inner (#a:Type) (#b:Type) (#len:size_nat) (f:(a -> Tot b)) (s:lseq a len) (i:size_nat{i < len}) = f s.[i] let map #a #b #len f s = createi #b len (map_inner #a #b #len f s) let map2i #a #b #c #len f s1 s2 = createi #c len (fun i -> f i s1.[i] s2.[i]) inline_for_extraction let map2_inner (#a:Type) (#b:Type) (#c:Type) (#len:size_nat) (f:(a -> b -> Tot c)) (s1:lseq a len) (s2:lseq b len) (i:size_nat{i < len}) = f s1.[i] s2.[i] let map2 #a #b #c #len f s1 s2 = createi #c len (map2_inner #a #b #c #len f s1 s2) let for_all #a #len f x = Seq.for_all f x let for_all2 #a #b #len f x y = let r = map2 (fun xi yi -> f xi yi) x y in Seq.for_all (fun bi -> bi = true) r (** Selecting a subset of an unbounded Sequence *) val seq_sub: #a:Type -> s1:seq a -> start:nat -> n:nat{start + n <= length s1} -> s2:seq a{length s2 == n /\ (forall (k:nat{k < n}). {:pattern (Seq.index s2 k)} Seq.index s2 k == Seq.index s1 (start + k))} let seq_sub #a s start n = Seq.slice #a s start (start + n) (** Updating a subset of an unbounded Sequence with another Sequence *) val seq_update_sub: #a:Type -> i:seq a -> start:nat -> n:nat{start + n <= length i} -> x:seq a{length x == n} -> o:seq a{length o == length i /\ seq_sub o start n == x /\ (forall (k:nat{(0 <= k /\ k < start) \/ (start + n <= k /\ k < length i)}). {:pattern (Seq.index o k)} Seq.index o k == Seq.index i k)} let seq_update_sub #a s start n x = let o = Seq.append (Seq.append (Seq.slice s 0 start) x) (Seq.slice s (start + n) (length s)) in Seq.lemma_eq_intro (Seq.slice o start (start + n)) x; o val repeati_blocks_f: #a:Type0 -> #b:Type0 -> blocksize:size_nat{blocksize > 0} -> inp:seq a -> f:(i:nat{i < length inp / blocksize} -> lseq a blocksize -> b -> b) -> nb:nat{nb == length inp / blocksize} -> i:nat{i < nb} -> acc:b -> b let repeati_blocks_f #a #b bs inp f nb i acc = assert ((i+1) * bs <= nb * bs); let block = seq_sub inp (i * bs) bs in f i block acc let repeati_blocks #a #b bs inp f g init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeati_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in g nb rem last acc let repeat_blocks #a #b #c bs inp f l init = let len = length inp in let nb = len / bs in let rem = len % bs in let acc = repeati nb (repeat_blocks_f bs inp f nb) init in let last = seq_sub inp (nb * bs) rem in l rem last acc let lemma_repeat_blocks #a #b #c bs inp f l init = () let repeat_blocks_multi #a #b bs inp f init = let len = length inp in let nb = len / bs in repeati nb (repeat_blocks_f bs inp f nb) init let lemma_repeat_blocks_multi #a #b bs inp f init = () let generate_blocks_a (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (i:nat{i <= max}) = a i & s:seq t{length s == i * blocklen} let generate_blocks_inner (t:Type) (blocklen:size_nat) (max:nat) (a:(i:nat{i <= max} -> Type)) (f:(i:nat{i < max} -> a i -> a (i + 1) & s:seq t{length s == blocklen})) (i:nat{i < max}) (acc:generate_blocks_a t blocklen max a i) : generate_blocks_a t blocklen max a (i + 1) = let acc, o = acc in let acc', block = f i acc in let o' : s:seq t{length s == ((i + 1) * blocklen)} = Seq.append o block in acc', o' let generate_blocks #t len max n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in repeat_gen n (generate_blocks_a t len max a) (generate_blocks_inner t len max a f) a0 let generate_blocks_simple_a (a:Type) (bs:size_nat) (max:nat) (i:nat{i <= max}) = s:seq a{length s == i * bs} let generate_blocks_simple_f (#a:Type) (bs:size_nat{bs > 0}) (max:nat) (f:(i:nat{i < max} -> lseq a bs)) (i:nat{i < max}) (acc:generate_blocks_simple_a a bs max i) : generate_blocks_simple_a a bs max (i + 1) = Seq.append acc (f i) let generate_blocks_simple #a bs max nb f = repeat_gen nb (generate_blocks_simple_a a bs max) (generate_blocks_simple_f #a bs max f) Seq.empty #restart-solver let div_interval b n i = Math.Lemmas.lemma_div_le (n * b) i b; Math.Lemmas.cancel_mul_div n b let mod_interval_lt b n i j = div_interval b n i; div_interval b n j let div_mul_lt b a n = () let mod_div_lt b i j = mod_interval_lt b (j / b) i j let div_mul_l a b c d = calc (==) { a / (c * d); == { } a / (d * c); == { Math.Lemmas.division_multiplication_lemma a d c } (a / d) / c; == { } (b / d) / c; == { Math.Lemmas.division_multiplication_lemma b d c } b / (d * c); == { } b / (c * d); } let map_blocks_multi #a bs max nb inp f = repeat_gen nb (map_blocks_a a bs max) (map_blocks_f #a bs max inp f) Seq.empty let lemma_map_blocks_multi #a bs max nb inp f = () private val mod_prop: n:pos -> a:nat -> b:nat{a * n <= b /\ b < (a + 1) * n} -> Lemma (b - a * n == b % n) let mod_prop n a b = Math.Lemmas.modulo_lemma (b - a * n) n; Math.Lemmas.lemma_mod_sub b n a #push-options "--z3rlimit 200" let rec index_map_blocks_multi #a bs max n inp f i = let map_blocks_a = map_blocks_a a bs max in let map_blocks_f = map_blocks_f #a bs max inp f in let acc0 = Seq.empty #a in let s1 = repeat_gen n map_blocks_a map_blocks_f acc0 in unfold_repeat_gen n map_blocks_a map_blocks_f acc0 (n-1); let s = repeat_gen (n-1) map_blocks_a map_blocks_f acc0 in //assert (s1 == map_blocks_f (n-1) s); let s' = f (n-1) (Seq.slice inp ((n-1)*bs) (n*bs)) in //assert (s1 == Seq.append s s'); if i < (n-1)*bs then begin Seq.lemma_index_app1 s s' i; index_map_blocks_multi #a bs max (n-1) inp f i end else begin Seq.lemma_index_app2 s s' i; mod_prop bs (n-1) i end let map_blocks #a blocksize inp f g = let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in let bs = map_blocks_multi #a blocksize nb nb blocks f in if (rem > 0) then Seq.append bs (g nb rem last) else bs let lemma_map_blocks #a blocksize inp f g = () let index_map_blocks #a bs inp f g i = let len = length inp in let nb = len / bs in let rem = len % bs in let blocks = Seq.slice inp 0 (nb * bs) in if rem > 0 then begin let s1 = map_blocks_multi #a bs nb nb blocks f in let last = Seq.slice inp (nb * bs) len in calc (==) { length last; == { Seq.lemma_len_slice inp (nb * bs) len } len - nb * bs; == {mod_prop bs nb len} len % bs; == { } rem; }; let s2 = g nb rem last in assert (Seq.equal (map_blocks bs inp f g) (Seq.append s1 s2)); if i < nb * bs then begin div_mul_lt bs i nb; Seq.lemma_index_app1 s1 s2 i; index_map_blocks_multi bs nb nb blocks f i end else begin Seq.lemma_index_app2 s1 s2 i; mod_prop bs nb i end end else index_map_blocks_multi #a bs nb nb blocks f i let eq_generate_blocks0 #t len n a f acc0 = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n 0 a f acc0 == repeat_gen 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); eq_repeat_gen0 0 (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 let unfold_generate_blocks #t len n a f acc0 i = let a0 = (acc0, (Seq.empty <: s:seq t{length s == 0 * len})) in assert (generate_blocks #t len n (i+1) a f acc0 == repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0); unfold_repeat_gen (i+1) (generate_blocks_a t len n a) (generate_blocks_inner t len n a f) a0 i let rec index_generate_blocks #t len max n f i = assert (0 < n); let a_spec (i:nat{i <= max}) = unit in let _,s = generate_blocks #t len max (n-1) a_spec f () in let _,s' = f (n-1) () in let _,s1 = generate_blocks #t len max n a_spec f () in unfold_generate_blocks #t len max a_spec f () (n-1); Seq.Properties.lemma_split s1 (n * len - len); Seq.Properties.lemma_split (Seq.append s s') (n * len - len); Seq.lemma_eq_intro s1 (Seq.append s s'); if i < (n-1) * len then begin Seq.lemma_index_app1 s s' i; index_generate_blocks len max (n-1) f i end else begin Seq.lemma_index_app2 s s' i; mod_prop len (n-1) i end #push-options "--using_facts_from '+FStar.UInt.pow2_values'" let create2 #a x0 x1 = let l = [x0; x1] in assert_norm (List.Tot.length l = 2); createL l let create2_lemma #a x0 x1 = Seq.elim_of_list [x0; x1] let create4 #a x0 x1 x2 x3 = let l = [x0; x1; x2; x3] in assert_norm (List.Tot.length l = 4); createL l let create4_lemma #a x0 x1 x2 x3 = Seq.elim_of_list [x0; x1; x2; x3] let create8 #a x0 x1 x2 x3 x4 x5 x6 x7 = let l = [x0; x1; x2; x3; x4; x5; x6; x7] in assert_norm (List.Tot.length l = 8); createL l let create8_lemma #a x0 x1 x2 x3 x4 x5 x6 x7 = Seq.elim_of_list [x0; x1; x2; x3; x4; x5; x6; x7]
false
false
Lib.Sequence.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val create16: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a -> x4:a -> x5:a -> x6:a -> x7:a -> x8:a -> x9:a -> x10:a -> x11:a -> x12:a -> x13:a -> x14:a -> x15:a -> lseq a 16
[]
Lib.Sequence.create16
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: a -> x1: a -> x2: a -> x3: a -> x4: a -> x5: a -> x6: a -> x7: a -> x8: a -> x9: a -> x10: a -> x11: a -> x12: a -> x13: a -> x14: a -> x15: a -> Lib.Sequence.lseq a 16
{ "end_col": 11, "end_line": 398, "start_col": 71, "start_line": 395 }