file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.__elim_exists'
val __elim_exists' (#t: _) (#pred: (t -> Type0)) (#goal: _) (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal
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 = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf)
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 275, "start_col": 0, "start_line": 273 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: (exists (x: t). pred x) -> k: (x: t -> _: pred x -> Prims.squash goal) -> Prims.squash goal
Prims.Tot
[ "total" ]
[]
[ "Prims.l_Exists", "Prims.squash", "FStar.Squash.bind_squash", "Prims.dtuple2" ]
[]
false
false
true
false
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)
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.elim_exists
val elim_exists (t: term) : Tac (binding & binding)
val elim_exists (t: term) : Tac (binding & binding)
let elim_exists (t : term) : Tac (binding & binding) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf)
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 282, "start_col": 0, "start_line": 278 }
(* 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.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Tactics.NamedView.term", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.NamedView.binding", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.binding", "FStar.Stubs.Tactics.V2.Builtins.intro", "Prims.unit", "FStar.Tactics.V2.Derived.apply_lemma" ]
[]
false
true
false
false
false
let elim_exists (t: term) : Tac (binding & binding) =
apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf)
false
Hacl.Impl.K256.Verify.fst
Hacl.Impl.K256.Verify.fmul_eq_vartime
val fmul_eq_vartime (r z x: felem) : Stack bool (requires fun h -> live h r /\ live h z /\ live h x /\ eq_or_disjoint r z /\ felem_fits5 (as_felem5 h r) (2,2,2,2,2) /\ as_nat h r < S.prime /\ inv_lazy_reduced2 h z /\ inv_fully_reduced h x) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (S.fmul (as_nat h0 r) (feval h0 z) = as_nat h0 x))
val fmul_eq_vartime (r z x: felem) : Stack bool (requires fun h -> live h r /\ live h z /\ live h x /\ eq_or_disjoint r z /\ felem_fits5 (as_felem5 h r) (2,2,2,2,2) /\ as_nat h r < S.prime /\ inv_lazy_reduced2 h z /\ inv_fully_reduced h x) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (S.fmul (as_nat h0 r) (feval h0 z) = as_nat h0 x))
let fmul_eq_vartime r z x = push_frame (); let tmp = create_felem () in fmul tmp r z; let h1 = ST.get () in fnormalize tmp tmp; let h2 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (as_felem5 h1 tmp); assert (inv_fully_reduced h2 tmp); let b = is_felem_eq_vartime tmp x in pop_frame (); b
{ "file_name": "code/k256/Hacl.Impl.K256.Verify.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 71, "start_col": 0, "start_line": 60 }
module Hacl.Impl.K256.Verify open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module S = Spec.K256 module KL = Spec.K256.Lemmas open Hacl.K256.Field open Hacl.Impl.K256.Point open Hacl.Impl.K256.PointMul open Hacl.Impl.K256.GLV module QA = Hacl.K256.Scalar module QI = Hacl.Impl.K256.Qinv module BL = Hacl.Spec.K256.Field52.Lemmas module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_verify_get_u12 (u1 u2 r s z: QA.qelem) : Stack unit (requires fun h -> live h r /\ live h s /\ live h z /\ live h u1 /\ live h u2 /\ disjoint u1 u2 /\ disjoint u1 z /\ disjoint u1 r /\ disjoint u1 s /\ disjoint u2 z /\ disjoint u2 r /\ disjoint u2 s /\ QA.qas_nat h s < S.q /\ QA.qas_nat h z < S.q /\ QA.qas_nat h r < S.q) (ensures fun h0 _ h1 -> modifies (loc u1 |+| loc u2) h0 h1 /\ (let sinv = S.qinv (QA.qas_nat h0 s) in QA.qas_nat h1 u1 == QA.qas_nat h0 z * sinv % S.q /\ QA.qas_nat h1 u2 == QA.qas_nat h0 r * sinv % S.q)) let ecdsa_verify_get_u12 u1 u2 r s z = push_frame (); let sinv = QA.create_qelem () in QI.qinv sinv s; QA.qmul u1 z sinv; QA.qmul u2 r sinv; pop_frame () val fmul_eq_vartime (r z x: felem) : Stack bool (requires fun h -> live h r /\ live h z /\ live h x /\ eq_or_disjoint r z /\ felem_fits5 (as_felem5 h r) (2,2,2,2,2) /\ as_nat h r < S.prime /\ inv_lazy_reduced2 h z /\ inv_fully_reduced h x) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (S.fmul (as_nat h0 r) (feval h0 z) = as_nat h0 x))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.Qinv.fst.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.GLV.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.K256.Verify.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "QA" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Field", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Hacl.K256.Field.felem -> z: Hacl.K256.Field.felem -> x: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Field.felem", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.K256.Field.is_felem_eq_vartime", "Prims._assert", "Hacl.K256.Field.inv_fully_reduced", "Hacl.Spec.K256.Field52.Lemmas.normalize5_lemma", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.K256.Field.as_felem5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Field.fnormalize", "Hacl.K256.Field.fmul", "Hacl.K256.Field.create_felem", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let fmul_eq_vartime r z x =
push_frame (); let tmp = create_felem () in fmul tmp r z; let h1 = ST.get () in fnormalize tmp tmp; let h2 = ST.get () in BL.normalize5_lemma (1, 1, 1, 1, 2) (as_felem5 h1 tmp); assert (inv_fully_reduced h2 tmp); let b = is_felem_eq_vartime tmp x in pop_frame (); b
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.as_subst
val as_subst (p: list (term & term)) (out: list subst_elt) (domain: list var) (codomain: Set.set var) : option (list subst_elt)
val as_subst (p: list (term & term)) (out: list subst_elt) (domain: list var) (codomain: Set.set var) : option (list subst_elt)
let rec as_subst (p : list (term & term)) (out:list subst_elt) (domain:list var) (codomain:Set.set var) : option (list subst_elt) = match p with | [] -> if disjoint domain codomain then Some out else None | (e1, e2)::p -> ( match e1.t with | Tm_FStar e1 -> ( match R.inspect_ln e1 with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in as_subst p (NT nv.uniq e2::out) (nv.uniq ::domain ) (Set.union codomain (freevars e2)) ) | _ -> None ) | _ -> None )
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 243, "start_col": 0, "start_line": 219 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report" let rec open_binders (g:env) (bs:list binder) (uvs:env { disjoint uvs g }) (v:term) (body:st_term) : T.Tac (uvs:env { disjoint uvs g } & term & st_term) = match bs with | [] -> (| uvs, v, body |) | b::bs -> // these binders are only lax checked so far let _ = PC.check_universe (push_env g uvs) b.binder_ty in let x = fresh (push_env g uvs) in let ss = [ DT 0 (tm_var {nm_index=x;nm_ppname=b.binder_ppname}) ] in let bs = L.mapi (fun i b -> assume (i >= 0); subst_binder b (shift_subst_n i ss)) bs in let v = subst_term v (shift_subst_n (L.length bs) ss) in let body = subst_st_term body (shift_subst_n (L.length bs) ss) in open_binders g bs (push_binding uvs x b.binder_ppname b.binder_ty) v body let closing (bs:list (ppname & var & typ)) : subst = L.fold_right (fun (_, x, _) (n, ss) -> n+1, (ND x n)::ss ) bs (0, []) |> snd let rec close_binders (bs:list (ppname & var & typ)) : Tot (list binder) (decreases L.length bs) = match bs with | [] -> [] | (name, x, t)::bs -> let bss = L.mapi (fun n (n1, x1, t1) -> assume (n >= 0); n1, x1, subst_term t1 [ND x n]) bs in let b = mk_binder_ppname t name in assume (L.length bss == L.length bs); b::(close_binders bss) let unfold_defs (g:env) (defs:option (list string)) (t:term) : T.Tac term = let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> ( let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty ) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t)) let check_unfoldable g (v:term) : T.Tac unit = match v.t with | Tm_FStar _ -> () | _ -> fail g (Some v.range) (Printf.sprintf "`fold` and `unfold` expect a single user-defined predicate as an argument, \ but %s is a primitive term that cannot be folded or unfolded" (P.term_to_string v)) let visit_and_rewrite (p: (R.term & R.term)) (t:term) : T.Tac term = let open FStar.Reflection.V2.TermEq in let lhs, rhs = p in let visitor (t:R.term) : T.Tac R.term = if term_eq t lhs then rhs else t in match R.inspect_ln lhs with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in assume (is_host_term rhs); subst_term t [NT nv.uniq { t = Tm_FStar rhs; range = t.range }] ) | _ -> let rec aux (t:term) : T.Tac term = match t.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Inames | Tm_Unknown -> t | Tm_Inv i -> { t with t = Tm_Inv (aux i) } | Tm_AddInv i is -> { t with t = Tm_AddInv (aux i) (aux is) } | Tm_Pure p -> { t with t = Tm_Pure (aux p) } | Tm_Star l r -> { t with t = Tm_Star (aux l) (aux r) } | Tm_ExistsSL u b body -> { t with t = Tm_ExistsSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_ForallSL u b body -> { t with t = Tm_ForallSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_FStar h -> let h = FStar.Tactics.Visit.visit_tm visitor h in assume (is_host_term h); { t with t=Tm_FStar h } in aux t let visit_and_rewrite_conjuncts (p: (R.term & R.term)) (tms:list term) : T.Tac (list term) = T.map (visit_and_rewrite p) tms let visit_and_rewrite_conjuncts_all (p: list (R.term & R.term)) (goal:term) : T.Tac (term & term) = let tms = Pulse.Typing.Combinators.vprop_as_list goal in let tms' = T.fold_left (fun tms p -> visit_and_rewrite_conjuncts p tms) tms p in assume (L.length tms' == L.length tms); let lhs, rhs = T.fold_left2 (fun (lhs, rhs) t t' -> if eq_tm t t' then lhs, rhs else (t::lhs, t'::rhs)) ([], []) tms tms' in Pulse.Typing.Combinators.list_as_vprop lhs, Pulse.Typing.Combinators.list_as_vprop rhs let disjoint (dom:list var) (cod:Set.set var) = L.for_all (fun d -> not (Set.mem d cod)) dom
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Prims.list (Pulse.Syntax.Base.term * Pulse.Syntax.Base.term) -> out: Prims.list Pulse.Syntax.Naming.subst_elt -> domain: Prims.list Pulse.Syntax.Base.var -> codomain: FStar.Set.set Pulse.Syntax.Base.var -> FStar.Pervasives.Native.option (Prims.list Pulse.Syntax.Naming.subst_elt)
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.term", "Pulse.Syntax.Naming.subst_elt", "Pulse.Syntax.Base.var", "FStar.Set.set", "Pulse.Checker.AssertWithBinders.disjoint", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.namedv", "Pulse.Checker.AssertWithBinders.as_subst", "Prims.Cons", "Pulse.Syntax.Naming.NT", "FStar.Stubs.Reflection.V2.Data.__proj__Mknamedv_view__item__uniq", "FStar.Set.union", "Pulse.Syntax.Naming.freevars", "FStar.Stubs.Reflection.V2.Data.namedv_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_namedv", "FStar.Stubs.Reflection.V2.Data.term_view", "Pulse.Syntax.Base.term'" ]
[ "recursion" ]
false
false
false
true
false
let rec as_subst (p: list (term & term)) (out: list subst_elt) (domain: list var) (codomain: Set.set var) : option (list subst_elt) =
match p with | [] -> if disjoint domain codomain then Some out else None | (e1, e2) :: p -> (match e1.t with | Tm_FStar e1 -> (match R.inspect_ln e1 with | R.Tv_Var n -> (let nv = R.inspect_namedv n in as_subst p (NT nv.uniq e2 :: out) (nv.uniq :: domain) (Set.union codomain (freevars e2)) ) | _ -> None) | _ -> None)
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.check_wild
val check_wild (g: env) (pre: term) (st: st_term{head_wild st}) : T.Tac st_term
val check_wild (g: env) (pre: term) (st: st_term{head_wild st}) : T.Tac st_term
let check_wild (g:env) (pre:term) (st:st_term { head_wild st }) : T.Tac st_term = let Tm_ProofHintWithBinders ht = st.term in let { binders=bs; t=body } = ht in match bs with | [] -> fail g (Some st.range) "A wildcard must have at least one binder" | _ -> let vprops = Pulse.Typing.Combinators.vprop_as_list pre in let ex, rest = List.Tot.partition (fun (v:vprop) -> Tm_ExistsSL? v.t) vprops in match ex with | [] | _::_::_ -> fail g (Some st.range) "Binding names with a wildcard requires exactly one existential quantifier in the goal" | [ex] -> let k = List.Tot.length bs in let rec peel_binders (n:nat) (t:term) : T.Tac st_term = if n = 0 then ( let ex_body = t in { st with term = Tm_ProofHintWithBinders { ht with hint_type = ASSERT { p = ex_body } }} ) else ( match t.t with | Tm_ExistsSL u b body -> peel_binders (n-1) body | _ -> fail g (Some st.range) (Printf.sprintf "Expected an existential quantifier with at least %d binders; but only found %s with %d binders" k (show ex) (k - n)) ) in peel_binders k ex
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 334, "start_col": 0, "start_line": 299 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report" let rec open_binders (g:env) (bs:list binder) (uvs:env { disjoint uvs g }) (v:term) (body:st_term) : T.Tac (uvs:env { disjoint uvs g } & term & st_term) = match bs with | [] -> (| uvs, v, body |) | b::bs -> // these binders are only lax checked so far let _ = PC.check_universe (push_env g uvs) b.binder_ty in let x = fresh (push_env g uvs) in let ss = [ DT 0 (tm_var {nm_index=x;nm_ppname=b.binder_ppname}) ] in let bs = L.mapi (fun i b -> assume (i >= 0); subst_binder b (shift_subst_n i ss)) bs in let v = subst_term v (shift_subst_n (L.length bs) ss) in let body = subst_st_term body (shift_subst_n (L.length bs) ss) in open_binders g bs (push_binding uvs x b.binder_ppname b.binder_ty) v body let closing (bs:list (ppname & var & typ)) : subst = L.fold_right (fun (_, x, _) (n, ss) -> n+1, (ND x n)::ss ) bs (0, []) |> snd let rec close_binders (bs:list (ppname & var & typ)) : Tot (list binder) (decreases L.length bs) = match bs with | [] -> [] | (name, x, t)::bs -> let bss = L.mapi (fun n (n1, x1, t1) -> assume (n >= 0); n1, x1, subst_term t1 [ND x n]) bs in let b = mk_binder_ppname t name in assume (L.length bss == L.length bs); b::(close_binders bss) let unfold_defs (g:env) (defs:option (list string)) (t:term) : T.Tac term = let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> ( let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty ) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t)) let check_unfoldable g (v:term) : T.Tac unit = match v.t with | Tm_FStar _ -> () | _ -> fail g (Some v.range) (Printf.sprintf "`fold` and `unfold` expect a single user-defined predicate as an argument, \ but %s is a primitive term that cannot be folded or unfolded" (P.term_to_string v)) let visit_and_rewrite (p: (R.term & R.term)) (t:term) : T.Tac term = let open FStar.Reflection.V2.TermEq in let lhs, rhs = p in let visitor (t:R.term) : T.Tac R.term = if term_eq t lhs then rhs else t in match R.inspect_ln lhs with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in assume (is_host_term rhs); subst_term t [NT nv.uniq { t = Tm_FStar rhs; range = t.range }] ) | _ -> let rec aux (t:term) : T.Tac term = match t.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Inames | Tm_Unknown -> t | Tm_Inv i -> { t with t = Tm_Inv (aux i) } | Tm_AddInv i is -> { t with t = Tm_AddInv (aux i) (aux is) } | Tm_Pure p -> { t with t = Tm_Pure (aux p) } | Tm_Star l r -> { t with t = Tm_Star (aux l) (aux r) } | Tm_ExistsSL u b body -> { t with t = Tm_ExistsSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_ForallSL u b body -> { t with t = Tm_ForallSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_FStar h -> let h = FStar.Tactics.Visit.visit_tm visitor h in assume (is_host_term h); { t with t=Tm_FStar h } in aux t let visit_and_rewrite_conjuncts (p: (R.term & R.term)) (tms:list term) : T.Tac (list term) = T.map (visit_and_rewrite p) tms let visit_and_rewrite_conjuncts_all (p: list (R.term & R.term)) (goal:term) : T.Tac (term & term) = let tms = Pulse.Typing.Combinators.vprop_as_list goal in let tms' = T.fold_left (fun tms p -> visit_and_rewrite_conjuncts p tms) tms p in assume (L.length tms' == L.length tms); let lhs, rhs = T.fold_left2 (fun (lhs, rhs) t t' -> if eq_tm t t' then lhs, rhs else (t::lhs, t'::rhs)) ([], []) tms tms' in Pulse.Typing.Combinators.list_as_vprop lhs, Pulse.Typing.Combinators.list_as_vprop rhs let disjoint (dom:list var) (cod:Set.set var) = L.for_all (fun d -> not (Set.mem d cod)) dom let rec as_subst (p : list (term & term)) (out:list subst_elt) (domain:list var) (codomain:Set.set var) : option (list subst_elt) = match p with | [] -> if disjoint domain codomain then Some out else None | (e1, e2)::p -> ( match e1.t with | Tm_FStar e1 -> ( match R.inspect_ln e1 with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in as_subst p (NT nv.uniq e2::out) (nv.uniq ::domain ) (Set.union codomain (freevars e2)) ) | _ -> None ) | _ -> None ) let rewrite_all (g:env) (p: list (term & term)) (t:term) : T.Tac (term & term) = match as_subst p [] [] Set.empty with | Some s -> t, subst_term t s | _ -> let p : list (R.term & R.term) = T.map (fun (e1, e2) -> elab_term (fst (Pulse.Checker.Pure.instantiate_term_implicits g e1)), elab_term (fst (Pulse.Checker.Pure.instantiate_term_implicits g e2))) p in let lhs, rhs = visit_and_rewrite_conjuncts_all p t in debug_log g (fun _ -> Printf.sprintf "Rewrote %s to %s" (P.term_to_string lhs) (P.term_to_string rhs)); lhs, rhs let check_renaming (g:env) (pre:term) (st:st_term { match st.term with | Tm_ProofHintWithBinders { hint_type = RENAME _ } -> true | _ -> false }) : T.Tac st_term = let Tm_ProofHintWithBinders ht = st.term in let { hint_type=RENAME { pairs; goal }; binders=bs; t=body } = ht in match bs, goal with | _::_, None -> //if there are binders, we must have a goal fail g (Some st.range) "A renaming with binders must have a goal (with xs. rename ... in goal)" | _::_, Some goal -> //rewrite it as // with bs. assert goal; // rename [pairs] in goal; // ... let body = {st with term = Tm_ProofHintWithBinders { ht with binders = [] }} in { st with term = Tm_ProofHintWithBinders { hint_type=ASSERT { p = goal }; binders=bs; t=body } } | [], None -> // if there is no goal, take the goal to be the full current pre let lhs, rhs = rewrite_all g pairs pre in let t = { st with term = Tm_Rewrite { t1 = lhs; t2 = rhs } } in { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } | [], Some goal -> ( let goal, _ = PC.instantiate_term_implicits g goal in let lhs, rhs = rewrite_all g pairs goal in let t = { st with term = Tm_Rewrite { t1 = lhs; t2 = rhs } } in { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } )
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> pre: Pulse.Syntax.Base.term -> st: Pulse.Syntax.Base.st_term{Pulse.Checker.AssertWithBinders.head_wild st} -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.st_term", "Prims.b2t", "Pulse.Checker.AssertWithBinders.head_wild", "Pulse.Syntax.Base.st_term'__Tm_ProofHintWithBinders__payload", "Pulse.Syntax.Base.proof_hint_type", "Prims.list", "Pulse.Syntax.Base.binder", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.range", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.vprop", "Prims.nat", "Prims.op_Equality", "Prims.int", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.Tm_ProofHintWithBinders", "Pulse.Syntax.Base.Mkst_term'__Tm_ProofHintWithBinders__payload", "Pulse.Syntax.Base.ASSERT", "Pulse.Syntax.Base.Mkproof_hint_type__ASSERT__payload", "Pulse.Syntax.Base.__proj__Mkst_term'__Tm_ProofHintWithBinders__payload__item__binders", "Pulse.Syntax.Base.__proj__Mkst_term'__Tm_ProofHintWithBinders__payload__item__t", "Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag", "Prims.bool", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.universe", "Prims.op_Subtraction", "Pulse.Syntax.Base.term'", "Prims.string", "FStar.Printf.sprintf", "Pulse.Show.show", "Pulse.Show.uu___30", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.partition", "Pulse.Syntax.Base.uu___is_Tm_ExistsSL", "Pulse.Typing.Combinators.vprop_as_list", "Pulse.Syntax.Base.st_term'", "Pulse.Syntax.Base.__proj__Mkst_term__item__term" ]
[]
false
true
false
false
false
let check_wild (g: env) (pre: term) (st: st_term{head_wild st}) : T.Tac st_term =
let Tm_ProofHintWithBinders ht = st.term in let { binders = bs ; t = body } = ht in match bs with | [] -> fail g (Some st.range) "A wildcard must have at least one binder" | _ -> let vprops = Pulse.Typing.Combinators.vprop_as_list pre in let ex, rest = List.Tot.partition (fun (v: vprop) -> Tm_ExistsSL? v.t) vprops in match ex with | [] | _ :: _ :: _ -> fail g (Some st.range) "Binding names with a wildcard requires exactly one existential quantifier in the goal" | [ex] -> let k = List.Tot.length bs in let rec peel_binders (n: nat) (t: term) : T.Tac st_term = if n = 0 then (let ex_body = t in { st with term = Tm_ProofHintWithBinders ({ ht with hint_type = ASSERT ({ p = ex_body }) }) }) else (match t.t with | Tm_ExistsSL u b body -> peel_binders (n - 1) body | _ -> fail g (Some st.range) (Printf.sprintf "Expected an existential quantifier with at least %d binders; but only found %s with %d binders" k (show ex) (k - n))) in peel_binders k ex
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.__lemma_to_squash
val __lemma_to_squash: #req: _ -> #ens: _ -> squash req -> h: (unit -> Lemma (requires req) (ensures ens)) -> squash ens
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 = h ()
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 109, "start_col": 0, "start_line": 108 }
(* 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.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.squash req -> h: (_: Prims.unit -> FStar.Pervasives.Lemma (requires req) (ensures ens)) -> Prims.squash ens
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "Prims.unit", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let __lemma_to_squash #req #ens (_: squash req) (h: (unit -> Lemma (requires req) (ensures ens))) : squash ens =
h ()
false
Lib.IntTypes.fst
Lib.IntTypes.conditional_subtract
val conditional_subtract: #t:inttype{signed t} -> #l:secrecy_level -> t':inttype{signed t' /\ bits t' < bits t} -> a:int_t t l{0 <= v a /\ v a <= pow2 (bits t') - 1} -> b:int_t t l{v b = v a @%. t'}
val conditional_subtract: #t:inttype{signed t} -> #l:secrecy_level -> t':inttype{signed t' /\ bits t' < bits t} -> a:int_t t l{0 <= v a /\ v a <= pow2 (bits t') - 1} -> b:int_t t l{v b = v a @%. t'}
let conditional_subtract #t #l t' a = assert_norm (pow2 7 = 128); assert_norm (pow2 15 = 32768); let pow2_bits = shift_left #t #l (mk_int 1) (size (bits t')) in shift_left_lemma #t #l (mk_int 1) (size (bits t')); let pow2_bits_minus_one = shift_left #t #l (mk_int 1) (size (bits t' - 1)) in shift_left_lemma #t #l (mk_int 1) (size (bits t' - 1)); // assert (v pow2_bits == pow2 (bits t')); // assert (v pow2_bits_minus_one == pow2 (bits t' - 1)); let a2 = a `sub` pow2_bits_minus_one in let mask = shift_right a2 (size (bits t - 1)) in shift_right_lemma a2 (size (bits t - 1)); // assert (if v a2 < 0 then v mask = -1 else v mask = 0); let a3 = a `sub` pow2_bits in logand_lemma mask pow2_bits; a3 `add` (mask `logand` pow2_bits)
{ "file_name": "lib/Lib.IntTypes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 1009, "start_col": 0, "start_line": 994 }
module Lib.IntTypes open FStar.Math.Lemmas #push-options "--max_fuel 0 --max_ifuel 1 --z3rlimit 200" let pow2_2 _ = assert_norm (pow2 2 = 4) let pow2_3 _ = assert_norm (pow2 3 = 8) let pow2_4 _ = assert_norm (pow2 4 = 16) let pow2_127 _ = assert_norm (pow2 127 = 0x80000000000000000000000000000000) let bits_numbytes t = () let sec_int_t t = pub_int_t t let sec_int_v #t u = pub_int_v u let secret #t x = x [@(strict_on_arguments [0])] let mk_int #t #l x = match t with | U1 -> UInt8.uint_to_t x | U8 -> UInt8.uint_to_t x | U16 -> UInt16.uint_to_t x | U32 -> UInt32.uint_to_t x | U64 -> UInt64.uint_to_t x | U128 -> UInt128.uint_to_t x | S8 -> Int8.int_to_t x | S16 -> Int16.int_to_t x | S32 -> Int32.int_to_t x | S64 -> Int64.int_to_t x | S128 -> Int128.int_to_t x val v_extensionality: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma (requires v a == v b) (ensures a == b) let v_extensionality #t #l a b = match t with | U1 -> () | U8 -> UInt8.v_inj a b | U16 -> UInt16.v_inj a b | U32 -> UInt32.v_inj a b | U64 -> UInt64.v_inj a b | U128 -> UInt128.v_inj a b | S8 -> Int8.v_inj a b | S16 -> Int16.v_inj a b | S32 -> Int32.v_inj a b | S64 -> Int64.v_inj a b | S128 -> Int128.v_inj a b let v_injective #t #l a = v_extensionality a (mk_int (v a)) let v_mk_int #t #l n = () let u128 n = FStar.UInt128.uint64_to_uint128 (u64 n) // KaRaMeL will extract this to FStar_Int128_int_to_t, which isn't provided // We'll need to have FStar.Int128.int64_to_int128 to support int128_t literals let i128 n = assert_norm (pow2 (bits S64 - 1) <= pow2 (bits S128 - 1)); sint #S128 #SEC n let size_to_uint32 x = x let size_to_uint64 x = Int.Cast.uint32_to_uint64 x let byte_to_uint8 x = x let byte_to_int8 x = Int.Cast.uint8_to_int8 x let op_At_Percent = Int.op_At_Percent // FStar.UInt128 gets special treatment in KaRaMeL. There is no // equivalent for FStar.Int128 at the moment, so we use the three // assumed cast operators below. // // Using them will fail at runtime with an informative message. // The commented-out implementations show that they are realizable. // // When support for `FStar.Int128` is added KaRaMeL, these casts must // be added as special cases. When using builtin compiler support for // `int128_t`, they can be implemented directly as C casts without // undefined or implementation-defined behaviour. assume val uint128_to_int128: a:UInt128.t{v a <= maxint S128} -> b:Int128.t{Int128.v b == UInt128.v a} //let uint128_to_int128 a = Int128.int_to_t (v a) assume val int128_to_uint128: a:Int128.t -> b:UInt128.t{UInt128.v b == Int128.v a % pow2 128} //let int128_to_uint128 a = mk_int (v a % pow2 128) assume val int64_to_int128: a:Int64.t -> b:Int128.t{Int128.v b == Int64.v a} //let int64_to_int128 a = Int128.int_to_t (v a) val uint64_to_int128: a:UInt64.t -> b:Int128.t{Int128.v b == UInt64.v a} let uint64_to_int128 a = uint128_to_int128 (Int.Cast.Full.uint64_to_uint128 a) val int64_to_uint128: a:Int64.t -> b:UInt128.t{UInt128.v b == Int64.v a % pow2 128} let int64_to_uint128 a = int128_to_uint128 (int64_to_int128 a) val int128_to_uint64: a:Int128.t -> b:UInt64.t{UInt64.v b == Int128.v a % pow2 64} let int128_to_uint64 a = Int.Cast.Full.uint128_to_uint64 (int128_to_uint128 a) #push-options "--z3rlimit 1000" [@(strict_on_arguments [0;2])] let cast #t #l t' l' u = assert_norm (pow2 8 = 2 * pow2 7); assert_norm (pow2 16 = 2 * pow2 15); assert_norm (pow2 64 * pow2 64 = pow2 128); assert_norm (pow2 16 * pow2 48 = pow2 64); assert_norm (pow2 8 * pow2 56 = pow2 64); assert_norm (pow2 32 * pow2 32 = pow2 64); modulo_modulo_lemma (v u) (pow2 32) (pow2 32); modulo_modulo_lemma (v u) (pow2 64) (pow2 64); modulo_modulo_lemma (v u) (pow2 128) (pow2 64); modulo_modulo_lemma (v u) (pow2 16) (pow2 48); modulo_modulo_lemma (v u) (pow2 8) (pow2 56); let open FStar.Int.Cast in let open FStar.Int.Cast.Full in match t, t' with | U1, U1 -> u | U1, U8 -> u | U1, U16 -> uint8_to_uint16 u | U1, U32 -> uint8_to_uint32 u | U1, U64 -> uint8_to_uint64 u | U1, U128 -> UInt128.uint64_to_uint128 (uint8_to_uint64 u) | U1, S8 -> uint8_to_int8 u | U1, S16 -> uint8_to_int16 u | U1, S32 -> uint8_to_int32 u | U1, S64 -> uint8_to_int64 u | U1, S128 -> uint64_to_int128 (uint8_to_uint64 u) | U8, U1 -> UInt8.rem u 2uy | U8, U8 -> u | U8, U16 -> uint8_to_uint16 u | U8, U32 -> uint8_to_uint32 u | U8, U64 -> uint8_to_uint64 u | U8, U128 -> UInt128.uint64_to_uint128 (uint8_to_uint64 u) | U8, S8 -> uint8_to_int8 u | U8, S16 -> uint8_to_int16 u | U8, S32 -> uint8_to_int32 u | U8, S64 -> uint8_to_int64 u | U8, S128 -> uint64_to_int128 (uint8_to_uint64 u) | U16, U1 -> UInt8.rem (uint16_to_uint8 u) 2uy | U16, U8 -> uint16_to_uint8 u | U16, U16 -> u | U16, U32 -> uint16_to_uint32 u | U16, U64 -> uint16_to_uint64 u | U16, U128 -> UInt128.uint64_to_uint128 (uint16_to_uint64 u) | U16, S8 -> uint16_to_int8 u | U16, S16 -> uint16_to_int16 u | U16, S32 -> uint16_to_int32 u | U16, S64 -> uint16_to_int64 u | U16, S128 -> uint64_to_int128 (uint16_to_uint64 u) | U32, U1 -> UInt8.rem (uint32_to_uint8 u) 2uy | U32, U8 -> uint32_to_uint8 u | U32, U16 -> uint32_to_uint16 u | U32, U32 -> u | U32, U64 -> uint32_to_uint64 u | U32, U128 -> UInt128.uint64_to_uint128 (uint32_to_uint64 u) | U32, S8 -> uint32_to_int8 u | U32, S16 -> uint32_to_int16 u | U32, S32 -> uint32_to_int32 u | U32, S64 -> uint32_to_int64 u | U32, S128 -> uint64_to_int128 (uint32_to_uint64 u) | U64, U1 -> UInt8.rem (uint64_to_uint8 u) 2uy | U64, U8 -> uint64_to_uint8 u | U64, U16 -> uint64_to_uint16 u | U64, U32 -> uint64_to_uint32 u | U64, U64 -> u | U64, U128 -> UInt128.uint64_to_uint128 u | U64, S8 -> uint64_to_int8 u | U64, S16 -> uint64_to_int16 u | U64, S32 -> uint64_to_int32 u | U64, S64 -> uint64_to_int64 u | U64, S128 -> uint64_to_int128 u | U128, U1 -> UInt8.rem (uint64_to_uint8 (uint128_to_uint64 u)) 2uy | U128, U8 -> uint64_to_uint8 (UInt128.uint128_to_uint64 u) | U128, U16 -> uint64_to_uint16 (UInt128.uint128_to_uint64 u) | U128, U32 -> uint64_to_uint32 (UInt128.uint128_to_uint64 u) | U128, U64 -> UInt128.uint128_to_uint64 u | U128, U128 -> u | U128, S8 -> uint64_to_int8 (UInt128.uint128_to_uint64 u) | U128, S16 -> uint64_to_int16 (UInt128.uint128_to_uint64 u) | U128, S32 -> uint64_to_int32 (UInt128.uint128_to_uint64 u) | U128, S64 -> uint64_to_int64 (UInt128.uint128_to_uint64 u) | U128, S128 -> uint128_to_int128 u | S8, U1 -> UInt8.rem (int8_to_uint8 u) 2uy | S8, U8 -> int8_to_uint8 u | S8, U16 -> int8_to_uint16 u | S8, U32 -> int8_to_uint32 u | S8, U64 -> int8_to_uint64 u | S8, U128 -> int64_to_uint128 (int8_to_int64 u) | S8, S8 -> u | S8, S16 -> int8_to_int16 u | S8, S32 -> int8_to_int32 u | S8, S64 -> int8_to_int64 u | S8, S128 -> int64_to_int128 (int8_to_int64 u) | S16, U1 -> UInt8.rem (int16_to_uint8 u) 2uy | S16, U8 -> int16_to_uint8 u | S16, U16 -> int16_to_uint16 u | S16, U32 -> int16_to_uint32 u | S16, U64 -> int16_to_uint64 u | S16, U128 -> int64_to_uint128 (int16_to_int64 u) | S16, S8 -> int16_to_int8 u | S16, S16 -> u | S16, S32 -> int16_to_int32 u | S16, S64 -> int16_to_int64 u | S16, S128 -> int64_to_int128 (int16_to_int64 u) | S32, U1 -> UInt8.rem (int32_to_uint8 u) 2uy | S32, U8 -> int32_to_uint8 u | S32, U16 -> int32_to_uint16 u | S32, U32 -> int32_to_uint32 u | S32, U64 -> int32_to_uint64 u | S32, U128 -> int64_to_uint128 (int32_to_int64 u) | S32, S8 -> int32_to_int8 u | S32, S16 -> int32_to_int16 u | S32, S32 -> u | S32, S64 -> int32_to_int64 u | S32, S128 -> int64_to_int128 (int32_to_int64 u) | S64, U1 -> UInt8.rem (int64_to_uint8 u) 2uy | S64, U8 -> int64_to_uint8 u | S64, U16 -> int64_to_uint16 u | S64, U32 -> int64_to_uint32 u | S64, U64 -> int64_to_uint64 u | S64, U128 -> int64_to_uint128 u | S64, S8 -> int64_to_int8 u | S64, S16 -> int64_to_int16 u | S64, S32 -> int64_to_int32 u | S64, S64 -> u | S64, S128 -> int64_to_int128 u | S128, U1 -> UInt8.rem (uint64_to_uint8 (int128_to_uint64 u)) 2uy | S128, U8 -> uint64_to_uint8 (int128_to_uint64 u) | S128, U16 -> uint64_to_uint16 (int128_to_uint64 u) | S128, U32 -> uint64_to_uint32 (int128_to_uint64 u) | S128, U64 -> int128_to_uint64 u | S128, U128 -> int128_to_uint128 u | S128, S8 -> uint64_to_int8 (int128_to_uint64 u) | S128, S16 -> uint64_to_int16 (int128_to_uint64 u) | S128, S32 -> uint64_to_int32 (int128_to_uint64 u) | S128, S64 -> uint64_to_int64 (int128_to_uint64 u) | S128, S128 -> u #pop-options [@(strict_on_arguments [0])] let ones t l = match t with | U1 -> 0x1uy | U8 -> 0xFFuy | U16 -> 0xFFFFus | U32 -> 0xFFFFFFFFul | U64 -> 0xFFFFFFFFFFFFFFFFuL | U128 -> let x = UInt128.uint64_to_uint128 0xFFFFFFFFFFFFFFFFuL in let y = (UInt128.shift_left x 64ul) `UInt128.add` x in assert_norm (UInt128.v y == pow2 128 - 1); y | _ -> mk_int (-1) let zeros t l = mk_int 0 [@(strict_on_arguments [0])] let add_mod #t #l a b = match t with | U1 -> UInt8.rem (UInt8.add_mod a b) 2uy | U8 -> UInt8.add_mod a b | U16 -> UInt16.add_mod a b | U32 -> UInt32.add_mod a b | U64 -> UInt64.add_mod a b | U128 -> UInt128.add_mod a b let add_mod_lemma #t #l a b = () [@(strict_on_arguments [0])] let add #t #l a b = match t with | U1 -> UInt8.add a b | U8 -> UInt8.add a b | U16 -> UInt16.add a b | U32 -> UInt32.add a b | U64 -> UInt64.add a b | U128 -> UInt128.add a b | S8 -> Int8.add a b | S16 -> Int16.add a b | S32 -> Int32.add a b | S64 -> Int64.add a b | S128 -> Int128.add a b let add_lemma #t #l a b = () #push-options "--max_fuel 1" [@(strict_on_arguments [0])] let incr #t #l a = match t with | U1 -> UInt8.add a 1uy | U8 -> UInt8.add a 1uy | U16 -> UInt16.add a 1us | U32 -> UInt32.add a 1ul | U64 -> UInt64.add a 1uL | U128 -> UInt128.add a (UInt128.uint_to_t 1) | S8 -> Int8.add a 1y | S16 -> Int16.add a 1s | S32 -> Int32.add a 1l | S64 -> Int64.add a 1L | S128 -> Int128.add a (Int128.int_to_t 1) let incr_lemma #t #l a = () #pop-options [@(strict_on_arguments [0])] let mul_mod #t #l a b = match t with | U1 -> UInt8.mul_mod a b | U8 -> UInt8.mul_mod a b | U16 -> UInt16.mul_mod a b | U32 -> UInt32.mul_mod a b | U64 -> UInt64.mul_mod a b let mul_mod_lemma #t #l a b = () [@(strict_on_arguments [0])] let mul #t #l a b = match t with | U1 -> UInt8.mul a b | U8 -> UInt8.mul a b | U16 -> UInt16.mul a b | U32 -> UInt32.mul a b | U64 -> UInt64.mul a b | S8 -> Int8.mul a b | S16 -> Int16.mul a b | S32 -> Int32.mul a b | S64 -> Int64.mul a b let mul_lemma #t #l a b = () let mul64_wide a b = UInt128.mul_wide a b let mul64_wide_lemma a b = () let mul_s64_wide a b = Int128.mul_wide a b let mul_s64_wide_lemma a b = () [@(strict_on_arguments [0])] let sub_mod #t #l a b = match t with | U1 -> UInt8.rem (UInt8.sub_mod a b) 2uy | U8 -> UInt8.sub_mod a b | U16 -> UInt16.sub_mod a b | U32 -> UInt32.sub_mod a b | U64 -> UInt64.sub_mod a b | U128 -> UInt128.sub_mod a b let sub_mod_lemma #t #l a b = () [@(strict_on_arguments [0])] let sub #t #l a b = match t with | U1 -> UInt8.sub a b | U8 -> UInt8.sub a b | U16 -> UInt16.sub a b | U32 -> UInt32.sub a b | U64 -> UInt64.sub a b | U128 -> UInt128.sub a b | S8 -> Int8.sub a b | S16 -> Int16.sub a b | S32 -> Int32.sub a b | S64 -> Int64.sub a b | S128 -> Int128.sub a b let sub_lemma #t #l a b = () #push-options "--max_fuel 1" [@(strict_on_arguments [0])] let decr #t #l a = match t with | U1 -> UInt8.sub a 1uy | U8 -> UInt8.sub a 1uy | U16 -> UInt16.sub a 1us | U32 -> UInt32.sub a 1ul | U64 -> UInt64.sub a 1uL | U128 -> UInt128.sub a (UInt128.uint_to_t 1) | S8 -> Int8.sub a 1y | S16 -> Int16.sub a 1s | S32 -> Int32.sub a 1l | S64 -> Int64.sub a 1L | S128 -> Int128.sub a (Int128.int_to_t 1) let decr_lemma #t #l a = () #pop-options [@(strict_on_arguments [0])] let logxor #t #l a b = match t with | U1 -> assert_norm (UInt8.logxor 0uy 0uy == 0uy); assert_norm (UInt8.logxor 0uy 1uy == 1uy); assert_norm (UInt8.logxor 1uy 0uy == 1uy); assert_norm (UInt8.logxor 1uy 1uy == 0uy); UInt8.logxor a b | U8 -> UInt8.logxor a b | U16 -> UInt16.logxor a b | U32 -> UInt32.logxor a b | U64 -> UInt64.logxor a b | U128 -> UInt128.logxor a b | S8 -> Int8.logxor a b | S16 -> Int16.logxor a b | S32 -> Int32.logxor a b | S64 -> Int64.logxor a b | S128 -> Int128.logxor a b #push-options "--max_fuel 1" val logxor_lemma_: #t:inttype -> #l:secrecy_level -> a:int_t t l -> b:int_t t l -> Lemma (v (a `logxor` (a `logxor` b)) == v b) let logxor_lemma_ #t #l a b = match t with | U1 | U8 | U16 | U32 | U64 | U128 -> UInt.logxor_associative #(bits t) (v a) (v a) (v b); UInt.logxor_self #(bits t) (v a); UInt.logxor_commutative #(bits t) 0 (v b); UInt.logxor_lemma_1 #(bits t) (v b) | S8 | S16 | S32 | S64 | S128 -> Int.logxor_associative #(bits t) (v a) (v a) (v b); Int.logxor_self #(bits t) (v a); Int.logxor_commutative #(bits t) 0 (v b); Int.logxor_lemma_1 #(bits t) (v b) let logxor_lemma #t #l a b = logxor_lemma_ #t a b; v_extensionality (logxor a (logxor a b)) b; begin match t with | U1 | U8 | U16 | U32 | U64 | U128 -> UInt.logxor_commutative #(bits t) (v a) (v b) | S8 | S16 | S32 | S64 | S128 -> Int.logxor_commutative #(bits t) (v a) (v b) end; v_extensionality (logxor a (logxor b a)) b; begin match t with | U1 | U8 | U16 | U32 | U64 | U128 -> UInt.logxor_lemma_1 #(bits t) (v a) | S8 | S16 | S32 | S64 | S128 -> Int.logxor_lemma_1 #(bits t) (v a) end; v_extensionality (logxor a (mk_int #t #l 0)) a let logxor_lemma1 #t #l a b = match v a, v b with | _, 0 -> UInt.logxor_lemma_1 #(bits t) (v a) | 0, _ -> UInt.logxor_commutative #(bits t) (v a) (v b); UInt.logxor_lemma_1 #(bits t) (v b) | 1, 1 -> v_extensionality a b; UInt.logxor_self #(bits t) (v a) let logxor_spec #t #l a b = match t with | U1 -> assert_norm (u1 0 `logxor` u1 0 == u1 0 /\ u1 0 `logxor` u1 1 == u1 1); assert_norm (u1 1 `logxor` u1 0 == u1 1 /\ u1 1 `logxor` u1 1 == u1 0); assert_norm (0 `logxor_v #U1` 0 == 0 /\ 0 `logxor_v #U1` 1 == 1); assert_norm (1 `logxor_v #U1` 0 == 1 /\ 1 `logxor_v #U1` 1 == 0) | _ -> () #pop-options [@(strict_on_arguments [0])] let logand #t #l a b = match t with | U1 -> assert_norm (UInt8.logand 0uy 0uy == 0uy); assert_norm (UInt8.logand 0uy 1uy == 0uy); assert_norm (UInt8.logand 1uy 0uy == 0uy); assert_norm (UInt8.logand 1uy 1uy == 1uy); UInt8.logand a b | U8 -> UInt8.logand a b | U16 -> UInt16.logand a b | U32 -> UInt32.logand a b | U64 -> UInt64.logand a b | U128 -> UInt128.logand a b | S8 -> Int8.logand a b | S16 -> Int16.logand a b | S32 -> Int32.logand a b | S64 -> Int64.logand a b | S128 -> Int128.logand a b let logand_zeros #t #l a = match t with | U1 -> assert_norm (u1 0 `logand` zeros U1 l == u1 0 /\ u1 1 `logand` zeros U1 l == u1 0) | U8 | U16 | U32 | U64 | U128 -> UInt.logand_lemma_1 #(bits t) (v a) | S8 | S16 | S32 | S64 | S128 -> Int.logand_lemma_1 #(bits t) (v a) let logand_ones #t #l a = match t with | U1 -> assert_norm (u1 0 `logand` ones U1 l == u1 0 /\ u1 1 `logand` ones U1 l == u1 1) | U8 | U16 | U32 | U64 | U128 -> UInt.logand_lemma_2 #(bits t) (v a) | S8 | S16 | S32 | S64 | S128 -> Int.logand_lemma_2 #(bits t) (v a) let logand_lemma #t #l a b = logand_zeros #t #l b; logand_ones #t #l b; match t with | U1 -> assert_norm (u1 0 `logand` zeros U1 l == u1 0 /\ u1 1 `logand` zeros U1 l == u1 0); assert_norm (u1 0 `logand` ones U1 l == u1 0 /\ u1 1 `logand` ones U1 l == u1 1) | U8 | U16 | U32 | U64 | U128 -> UInt.logand_commutative #(bits t) (v a) (v b) | S8 | S16 | S32 | S64 | S128 -> Int.logand_commutative #(bits t) (v a) (v b) let logand_spec #t #l a b = match t with | U1 -> assert_norm (u1 0 `logand` u1 0 == u1 0 /\ u1 0 `logand` u1 1 == u1 0); assert_norm (u1 1 `logand` u1 0 == u1 0 /\ u1 1 `logand` u1 1 == u1 1); assert_norm (0 `logand_v #U1` 0 == 0 /\ 0 `logand_v #U1` 1 == 0); assert_norm (1 `logand_v #U1` 0 == 0 /\ 1 `logand_v #U1` 1 == 1) | _ -> () let logand_le #t #l a b = match t with | U1 -> assert_norm (UInt8.logand 0uy 0uy == 0uy); assert_norm (UInt8.logand 0uy 1uy == 0uy); assert_norm (UInt8.logand 1uy 0uy == 0uy); assert_norm (UInt8.logand 1uy 1uy == 1uy) | U8 -> UInt.logand_le (UInt.to_uint_t 8 (v a)) (UInt.to_uint_t 8 (v b)) | U16 -> UInt.logand_le (UInt.to_uint_t 16 (v a)) (UInt.to_uint_t 16 (v b)) | U32 -> UInt.logand_le (UInt.to_uint_t 32 (v a)) (UInt.to_uint_t 32 (v b)) | U64 -> UInt.logand_le (UInt.to_uint_t 64 (v a)) (UInt.to_uint_t 64 (v b)) | U128 -> UInt.logand_le (UInt.to_uint_t 128 (v a)) (UInt.to_uint_t 128 (v b)) let logand_mask #t #l a b m = match t with | U1 -> assert_norm (UInt8.logand 0uy 0uy == 0uy); assert_norm (UInt8.logand 0uy 1uy == 0uy); assert_norm (UInt8.logand 1uy 0uy == 0uy); assert_norm (UInt8.logand 1uy 1uy == 1uy) | U8 -> UInt.logand_mask (UInt.to_uint_t 8 (v a)) m | U16 -> UInt.logand_mask (UInt.to_uint_t 16 (v a)) m | U32 -> UInt.logand_mask (UInt.to_uint_t 32 (v a)) m | U64 -> UInt.logand_mask (UInt.to_uint_t 64 (v a)) m | U128 -> UInt.logand_mask (UInt.to_uint_t 128 (v a)) m [@(strict_on_arguments [0])] let logor #t #l a b = match t with | U1 -> assert_norm (UInt8.logor 0uy 0uy == 0uy); assert_norm (UInt8.logor 0uy 1uy == 1uy); assert_norm (UInt8.logor 1uy 0uy == 1uy); assert_norm (UInt8.logor 1uy 1uy == 1uy); UInt8.logor a b | U8 -> UInt8.logor a b | U16 -> UInt16.logor a b | U32 -> UInt32.logor a b | U64 -> UInt64.logor a b | U128 -> UInt128.logor a b | S8 -> Int8.logor a b | S16 -> Int16.logor a b | S32 -> Int32.logor a b | S64 -> Int64.logor a b | S128 -> Int128.logor a b #push-options "--max_fuel 1" let logor_disjoint #t #l a b m = if m > 0 then begin UInt.logor_disjoint #(bits t) (v b) (v a) m; UInt.logor_commutative #(bits t) (v b) (v a) end else begin UInt.logor_commutative #(bits t) (v a) (v b); UInt.logor_lemma_1 #(bits t) (v b) end #pop-options let logor_zeros #t #l a = match t with |U1 -> assert_norm(u1 0 `logor` zeros U1 l == u1 0 /\ u1 1 `logor` zeros U1 l == u1 1) | U8 | U16 | U32 | U64 | U128 -> UInt.logor_lemma_1 #(bits t) (v a) | S8 | S16 | S32 | S64 | S128 -> Int.nth_lemma #(bits t) (Int.logor #(bits t) (v a) (Int.zero (bits t))) (v a) let logor_ones #t #l a = match t with |U1 -> assert_norm(u1 0 `logor` ones U1 l == u1 1 /\ u1 1 `logor` ones U1 l == u1 1) | U8 | U16 | U32 | U64 | U128 -> UInt.logor_lemma_2 #(bits t) (v a) | S8 | S16 | S32 | S64 | S128 -> Int.nth_lemma (Int.logor #(bits t) (v a) (Int.ones (bits t))) (Int.ones (bits t)) let logor_lemma #t #l a b = logor_zeros #t #l b; logor_ones #t #l b; match t with | U1 -> assert_norm(u1 0 `logor` ones U1 l == u1 1 /\ u1 1 `logor` ones U1 l == u1 1); assert_norm(u1 0 `logor` zeros U1 l == u1 0 /\ u1 1 `logor` zeros U1 l == u1 1) | U8 | U16 | U32 | U64 | U128 -> UInt.logor_commutative #(bits t) (v a) (v b) | S8 | S16 | S32 | S64 | S128 -> Int.nth_lemma #(bits t) (Int.logor #(bits t) (v a) (v b)) (Int.logor #(bits t) (v b) (v a)) let logor_spec #t #l a b = match t with | U1 -> assert_norm(u1 0 `logor` ones U1 l == u1 1 /\ u1 1 `logor` ones U1 l == u1 1); assert_norm(u1 0 `logor` zeros U1 l == u1 0 /\ u1 1 `logor` zeros U1 l == u1 1); assert_norm (0 `logor_v #U1` 0 == 0 /\ 0 `logor_v #U1` 1 == 1); assert_norm (1 `logor_v #U1` 0 == 1 /\ 1 `logor_v #U1` 1 == 1) | _ -> () [@(strict_on_arguments [0])] let lognot #t #l a = match t with | U1 -> UInt8.rem (UInt8.lognot a) 2uy | U8 -> UInt8.lognot a | U16 -> UInt16.lognot a | U32 -> UInt32.lognot a | U64 -> UInt64.lognot a | U128 -> UInt128.lognot a | S8 -> Int8.lognot a | S16 -> Int16.lognot a | S32 -> Int32.lognot a | S64 -> Int64.lognot a | S128 -> Int128.lognot a let lognot_lemma #t #l a = match t with |U1 -> assert_norm(lognot (u1 0) == u1 1 /\ lognot (u1 1) == u1 0) | U8 | U16 | U32 | U64 | U128 -> FStar.UInt.lognot_lemma_1 #(bits t); UInt.nth_lemma (FStar.UInt.lognot #(bits t) (UInt.ones (bits t))) (UInt.zero (bits t)) | S8 | S16 | S32 | S64 | S128 -> Int.nth_lemma (FStar.Int.lognot #(bits t) (Int.zero (bits t))) (Int.ones (bits t)); Int.nth_lemma (FStar.Int.lognot #(bits t) (Int.ones (bits t))) (Int.zero (bits t)) let lognot_spec #t #l a = match t with | U1 -> assert_norm(lognot (u1 0) == u1 1 /\ lognot (u1 1) == u1 0); assert_norm(lognot_v #U1 0 == 1 /\ lognot_v #U1 1 == 0) | _ -> () [@(strict_on_arguments [0])] let shift_right #t #l a b = match t with | U1 -> UInt8.shift_right a b | U8 -> UInt8.shift_right a b | U16 -> UInt16.shift_right a b | U32 -> UInt32.shift_right a b | U64 -> UInt64.shift_right a b | U128 -> UInt128.shift_right a b | S8 -> Int8.shift_arithmetic_right a b | S16 -> Int16.shift_arithmetic_right a b | S32 -> Int32.shift_arithmetic_right a b | S64 -> Int64.shift_arithmetic_right a b | S128 -> Int128.shift_arithmetic_right a b val shift_right_value_aux_1: #n:pos{1 < n} -> a:Int.int_t n -> s:nat{n <= s} -> Lemma (Int.shift_arithmetic_right #n a s = a / pow2 s) let shift_right_value_aux_1 #n a s = pow2_le_compat s n; if a >= 0 then Int.sign_bit_positive a else Int.sign_bit_negative a #push-options "--z3rlimit 200" val shift_right_value_aux_2: #n:pos{1 < n} -> a:Int.int_t n -> Lemma (Int.shift_arithmetic_right #n a 1 = a / 2) let shift_right_value_aux_2 #n a = if a >= 0 then begin Int.sign_bit_positive a; UInt.shift_right_value_aux_3 #n a 1 end else begin Int.sign_bit_negative a; let a1 = Int.to_vec a in let au = Int.to_uint a in let sar = Int.shift_arithmetic_right #n a 1 in let sar1 = Int.to_vec sar in let sr = UInt.shift_right #n au 1 in let sr1 = UInt.to_vec sr in assert (Seq.equal (Seq.slice sar1 1 n) (Seq.slice sr1 1 n)); assert (Seq.equal sar1 (Seq.append (BitVector.ones_vec #1) (Seq.slice sr1 1 n))); UInt.append_lemma #1 #(n-1) (BitVector.ones_vec #1) (Seq.slice sr1 1 n); assert (Seq.equal (Seq.slice a1 0 (n-1)) (Seq.slice sar1 1 n)); UInt.slice_left_lemma a1 (n-1); assert (sar + pow2 n = pow2 (n-1) + (au / 2)); pow2_double_sum (n-1); assert (sar + pow2 (n-1) = (a + pow2 n) / 2); pow2_double_mult (n-1); lemma_div_plus a (pow2 (n-1)) 2; assert (sar = a / 2) end val shift_right_value_aux_3: #n:pos -> a:Int.int_t n -> s:pos{s < n} -> Lemma (ensures Int.shift_arithmetic_right #n a s = a / pow2 s) (decreases s) let rec shift_right_value_aux_3 #n a s = if s = 1 then shift_right_value_aux_2 #n a else begin let a1 = Int.to_vec a in assert (Seq.equal (BitVector.shift_arithmetic_right_vec #n a1 s) (BitVector.shift_arithmetic_right_vec #n (BitVector.shift_arithmetic_right_vec #n a1 (s-1)) 1)); assert (Int.shift_arithmetic_right #n a s = Int.shift_arithmetic_right #n (Int.shift_arithmetic_right #n a (s-1)) 1); shift_right_value_aux_3 #n a (s-1); shift_right_value_aux_2 #n (Int.shift_arithmetic_right #n a (s-1)); assert (Int.shift_arithmetic_right #n a s = (a / pow2 (s-1)) / 2); pow2_double_mult (s-1); division_multiplication_lemma a (pow2 (s-1)) 2 end let shift_right_lemma #t #l a b = match t with | U1 | U8 | U16 | U32 | U64 | U128 -> () | S8 | S16 | S32 | S64 | S128 -> if v b = 0 then () else if v b >= bits t then shift_right_value_aux_1 #(bits t) (v a) (v b) else shift_right_value_aux_3 #(bits t) (v a) (v b) [@(strict_on_arguments [0])] let shift_left #t #l a b = match t with | U1 -> UInt8.shift_left a b | U8 -> UInt8.shift_left a b | U16 -> UInt16.shift_left a b | U32 -> UInt32.shift_left a b | U64 -> UInt64.shift_left a b | U128 -> UInt128.shift_left a b | S8 -> Int8.shift_left a b | S16 -> Int16.shift_left a b | S32 -> Int32.shift_left a b | S64 -> Int64.shift_left a b | S128 -> Int128.shift_left a b #push-options "--max_fuel 1" let shift_left_lemma #t #l a b = () let rotate_right #t #l a b = logor (shift_right a b) (shift_left a (sub #U32 (size (bits t)) b)) let rotate_left #t #l a b = logor (shift_left a b) (shift_right a (sub #U32 (size (bits t)) b)) [@(strict_on_arguments [0])] let ct_abs #t #l a = match t with | S8 -> Int8.ct_abs a | S16 -> Int16.ct_abs a | S32 -> Int32.ct_abs a | S64 -> Int64.ct_abs a #pop-options [@(strict_on_arguments [0])] let eq_mask #t a b = match t with | U1 -> lognot (logxor a b) | U8 -> UInt8.eq_mask a b | U16 -> UInt16.eq_mask a b | U32 -> UInt32.eq_mask a b | U64 -> UInt64.eq_mask a b | U128 -> UInt128.eq_mask a b | S8 -> Int.Cast.uint8_to_int8 (UInt8.eq_mask (to_u8 a) (to_u8 b)) | S16 -> Int.Cast.uint16_to_int16 (UInt16.eq_mask (to_u16 a) (to_u16 b)) | S32 -> Int.Cast.uint32_to_int32 (UInt32.eq_mask (to_u32 a) (to_u32 b)) | S64 -> Int.Cast.uint64_to_int64 (UInt64.eq_mask (to_u64 a) (to_u64 b)) val eq_mask_lemma_unsigned: #t:inttype{unsigned t} -> a:int_t t SEC -> b:int_t t SEC -> Lemma (if v a = v b then v (eq_mask a b) == ones_v t else v (eq_mask a b) == 0) let eq_mask_lemma_unsigned #t a b = match t with | U1 -> assert_norm ( logxor (u1 0) (u1 0) == u1 0 /\ logxor (u1 0) (u1 1) == u1 1 /\ logxor (u1 1) (u1 0) == u1 1 /\ logxor (u1 1) (u1 1) == u1 0 /\ lognot (u1 1) == u1 0 /\ lognot (u1 0) == u1 1) | U8 | U16 | U32 | U64 | U128 -> () #push-options "--z3rlimit 200" val eq_mask_lemma_signed: #t:inttype{signed t /\ ~(S128? t)} -> a:int_t t SEC -> b:int_t t SEC -> Lemma (if v a = v b then v (eq_mask a b) == ones_v t else v (eq_mask a b) == 0) let eq_mask_lemma_signed #t a b = match t with | S8 -> begin assert_norm (pow2 8 = 2 * pow2 7); if 0 <= v a then modulo_lemma (v a) (pow2 8) else begin modulo_addition_lemma (v a) 1 (pow2 8); modulo_lemma (v a + pow2 8) (pow2 8) end end | S16 -> begin assert_norm (pow2 16 = 2 * pow2 15); if 0 <= v a then modulo_lemma (v a) (pow2 16) else begin modulo_addition_lemma (v a) 1 (pow2 16); modulo_lemma (v a + pow2 16) (pow2 16) end end | S32 -> begin if 0 <= v a then modulo_lemma (v a) (pow2 32) else begin modulo_addition_lemma (v a) 1 (pow2 32); modulo_lemma (v a + pow2 32) (pow2 32) end end | S64 -> begin if 0 <= v a then modulo_lemma (v a) (pow2 64) else begin modulo_addition_lemma (v a) 1 (pow2 64); modulo_lemma (v a + pow2 64) (pow2 64) end end #pop-options let eq_mask_lemma #t a b = if signed t then eq_mask_lemma_signed a b else eq_mask_lemma_unsigned a b let eq_mask_logand_lemma #t a b c = eq_mask_lemma a b; logand_zeros c; logand_ones c; match t with | U1 | U8 | U16 | U32 | U64 | U128 -> UInt.logand_commutative #(bits t) (v (eq_mask a b)) (v c) | S8 | S16 | S32 | S64 -> Int.logand_commutative #(bits t) (v (eq_mask a b)) (v c) [@(strict_on_arguments [0])] let neq_mask #t a b = lognot (eq_mask #t a b) let neq_mask_lemma #t a b = match t with | U1 -> assert_norm (lognot (u1 1) == u1 0 /\ lognot (u1 0) == u1 1) | _ -> UInt.lognot_lemma_1 #(bits t); UInt.lognot_self #(bits t) 0 [@(strict_on_arguments [0])] let gte_mask #t a b = match t with | U1 -> logor a (lognot b) | U8 -> UInt8.gte_mask a b | U16 -> UInt16.gte_mask a b | U32 -> UInt32.gte_mask a b | U64 -> UInt64.gte_mask a b | U128 -> UInt128.gte_mask a b let gte_mask_lemma #t a b = match t with | U1 -> begin assert_norm ( logor (u1 0) (u1 0) == u1 0 /\ logor (u1 1) (u1 1) == u1 1 /\ logor (u1 0) (u1 1) == u1 1 /\ logor (u1 1) (u1 0) == u1 1 /\ lognot (u1 1) == u1 0 /\ lognot (u1 0) == u1 1) end | _ -> () let gte_mask_logand_lemma #t a b c = logand_zeros c; logand_ones c; match t with | U1 -> assert_norm ( logor (u1 0) (u1 0) == u1 0 /\ logor (u1 1) (u1 1) == u1 1 /\ logor (u1 0) (u1 1) == u1 1 /\ logor (u1 1) (u1 0) == u1 1 /\ lognot (u1 1) == u1 0 /\ lognot (u1 0) == u1 1) | _ -> UInt.logand_commutative #(bits t) (v (gte_mask a b)) (v c) let lt_mask #t a b = lognot (gte_mask a b) let lt_mask_lemma #t a b = assert_norm (lognot (u1 1) == u1 0 /\ lognot (u1 0) == u1 1); UInt.lognot_lemma_1 #(bits t); UInt.lognot_self #(bits t) 0 let gt_mask #t a b = logand (gte_mask a b) (neq_mask a b) let gt_mask_lemma #t a b = logand_zeros (gte_mask a b); logand_ones (gte_mask a b) let lte_mask #t a b = logor (lt_mask a b) (eq_mask a b) let lte_mask_lemma #t a b = match t with | U1 -> assert_norm ( logor (u1 0) (u1 0) == u1 0 /\ logor (u1 1) (u1 1) == u1 1 /\ logor (u1 0) (u1 1) == u1 1 /\ logor (u1 1) (u1 0) == u1 1) | U8 | U16 | U32 | U64 | U128 -> if v a > v b then UInt.logor_lemma_1 #(bits t) (v (lt_mask a b)) else if v a = v b then UInt.logor_lemma_2 #(bits t) (v (lt_mask a b)) else UInt.logor_lemma_1 #(bits t) (v (lt_mask a b)) #push-options "--max_fuel 1" val mod_mask_value: #t:inttype -> #l:secrecy_level -> m:shiftval t{pow2 (uint_v m) <= maxint t} -> Lemma (v (mod_mask #t #l m) == pow2 (v m) - 1) let mod_mask_value #t #l m = shift_left_lemma (mk_int #t #l 1) m; pow2_double_mult (bits t - 1); pow2_lt_compat (bits t) (v m); small_modulo_lemma_1 (pow2 (v m)) (pow2 (bits t)); small_modulo_lemma_1 (pow2 (v m) - 1) (pow2 (bits t)) let mod_mask_lemma #t #l a m = mod_mask_value #t #l m; if unsigned t || 0 <= v a then if v m = 0 then UInt.logand_lemma_1 #(bits t) (v a) else UInt.logand_mask #(bits t) (v a) (v m) else begin let a1 = v a in let a2 = v a + pow2 (bits t) in pow2_plus (bits t - v m) (v m); pow2_le_compat (bits t - 1) (v m); lemma_mod_plus a1 (pow2 (bits t - v m)) (pow2 (v m)); if v m = 0 then UInt.logand_lemma_1 #(bits t) a2 else UInt.logand_mask #(bits t) a2 (v m) end #pop-options #push-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 1000" (** Conditionally subtracts 2^(bits t') from a in constant-time, so that the result fits in t'; i.e. b = if a >= 2^(bits t' - 1) then a - 2^(bits t') else a *) inline_for_extraction val conditional_subtract: #t:inttype{signed t} -> #l:secrecy_level -> t':inttype{signed t' /\ bits t' < bits t} -> a:int_t t l{0 <= v a /\ v a <= pow2 (bits t') - 1}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt128.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int128.fsti.checked", "FStar.Int.Cast.Full.fst.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "Lib.IntTypes.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "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 } ]
{ "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": 1000, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t': Lib.IntTypes.inttype{Lib.IntTypes.signed t' /\ Lib.IntTypes.bits t' < Lib.IntTypes.bits t} -> a: Lib.IntTypes.int_t t l {0 <= Lib.IntTypes.v a /\ Lib.IntTypes.v a <= Prims.pow2 (Lib.IntTypes.bits t') - 1} -> b: Lib.IntTypes.int_t t l {Lib.IntTypes.v b = Lib.IntTypes.v a @%. t'}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.inttype", "Prims.b2t", "Lib.IntTypes.signed", "Lib.IntTypes.secrecy_level", "Prims.l_and", "Prims.op_LessThan", "Lib.IntTypes.bits", "Lib.IntTypes.int_t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.add", "Lib.IntTypes.logand", "Prims.unit", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.sub", "Lib.IntTypes.shift_right_lemma", "Lib.IntTypes.size", "Lib.IntTypes.shift_right", "Lib.IntTypes.shift_left_lemma", "Lib.IntTypes.mk_int", "Lib.IntTypes.shift_left", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.op_At_Percent_Dot" ]
[]
false
false
false
false
false
let conditional_subtract #t #l t' a =
assert_norm (pow2 7 = 128); assert_norm (pow2 15 = 32768); let pow2_bits = shift_left #t #l (mk_int 1) (size (bits t')) in shift_left_lemma #t #l (mk_int 1) (size (bits t')); let pow2_bits_minus_one = shift_left #t #l (mk_int 1) (size (bits t' - 1)) in shift_left_lemma #t #l (mk_int 1) (size (bits t' - 1)); let a2 = a `sub` pow2_bits_minus_one in let mask = shift_right a2 (size (bits t - 1)) in shift_right_lemma a2 (size (bits t - 1)); let a3 = a `sub` pow2_bits in logand_lemma mask pow2_bits; a3 `add` (mask `logand` pow2_bits)
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.instantiate
val instantiate (fa x: term) : Tac binding
val instantiate (fa x: term) : Tac binding
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"
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 296, "start_col": 0, "start_line": 293 }
(* 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.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fa: FStar.Tactics.NamedView.term -> x: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
FStar.Tactics.Effect.Tac
[]
[]
[ "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" ]
[]
false
true
false
false
false
let instantiate (fa x: term) : Tac binding =
try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.infer_binder_types
val infer_binder_types (g: env) (bs: list binder) (v: vprop) : T.Tac (list binder)
val infer_binder_types (g: env) (bs: list binder) (v: vprop) : T.Tac (list binder)
let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report"
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 106, "end_line": 89, "start_col": 0, "start_line": 58 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> bs: Prims.list Pulse.Syntax.Base.binder -> v: Pulse.Syntax.Base.vprop -> FStar.Tactics.Effect.Tac (Prims.list Pulse.Syntax.Base.binder)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Prims.list", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.vprop", "Prims.Nil", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "Pulse.Syntax.Base.host_term", "Pulse.Checker.AssertWithBinders.refl_abs_binders", "Pulse.Syntax.Base.term'", "FStar.Tactics.V2.Derived.fail", "FStar.Pervasives.Native.tuple2", "Pulse.Checker.Pure.instantiate_term_implicits", "Pulse.Syntax.Base.tm_fstar", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "FStar.List.Tot.Base.fold_right", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_Abs", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.V2.Builtins.pack_binder", "FStar.Stubs.Reflection.V2.Data.binder_view", "FStar.Stubs.Reflection.V2.Data.Mkbinder_view", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Stubs.Reflection.Types.term", "Pulse.Syntax.Base.__proj__Mkppname__item__name", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "Prims.unit", "Prims.op_Negation", "Pulse.Checker.AssertWithBinders.is_host_term", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.range", "Prims.string", "FStar.Printf.sprintf", "Pulse.Syntax.Printer.term_to_string", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "Prims.bool", "Prims.eq2", "Pulse.Typing.Env.push_context" ]
[]
false
true
false
false
false
let infer_binder_types (g: env) (bs: list binder) (v: vprop) : T.Tac (list binder) =
match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b: binder) : R.binder = let open R in let bv:binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv: host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report"
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.__forall_inst_sq
val __forall_inst_sq (#t: _) (#pred: (t -> Type0)) (h: squash (forall x. pred x)) (x: t) : squash (pred x)
val __forall_inst_sq (#t: _) (#pred: (t -> Type0)) (h: squash (forall x. pred x)) (x: t) : squash (pred x)
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)
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 291, "start_col": 0, "start_line": 290 }
(* 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.Stubs.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 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: Prims.squash (forall (x: t). pred x) -> x: t -> Prims.squash (pred x)
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "Prims.l_Forall", "FStar.Squash.bind_squash", "FStar.Tactics.V2.Logic.__forall_inst" ]
[]
false
false
true
false
false
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
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.instantiate_as
val instantiate_as (fa x: term) (s: string) : Tac binding
val instantiate_as (fa x: term) (s: string) : Tac binding
let instantiate_as (fa : term) (x : term) (s : string) : Tac binding = let b = instantiate fa x in rename_to b s
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 300, "start_col": 0, "start_line": 298 }
(* 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.Stubs.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"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fa: FStar.Tactics.NamedView.term -> x: FStar.Tactics.NamedView.term -> s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Tactics.NamedView.term", "Prims.string", "FStar.Stubs.Tactics.V2.Builtins.rename_to", "FStar.Stubs.Reflection.V2.Data.binding", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.instantiate" ]
[]
false
true
false
false
false
let instantiate_as (fa x: term) (s: string) : Tac binding =
let b = instantiate fa x in rename_to b s
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.check_renaming
val check_renaming (g: env) (pre: term) (st: st_term { match st.term with | Tm_ProofHintWithBinders { hint_type = RENAME _ } -> true | _ -> false }) : T.Tac st_term
val check_renaming (g: env) (pre: term) (st: st_term { match st.term with | Tm_ProofHintWithBinders { hint_type = RENAME _ } -> true | _ -> false }) : T.Tac st_term
let check_renaming (g:env) (pre:term) (st:st_term { match st.term with | Tm_ProofHintWithBinders { hint_type = RENAME _ } -> true | _ -> false }) : T.Tac st_term = let Tm_ProofHintWithBinders ht = st.term in let { hint_type=RENAME { pairs; goal }; binders=bs; t=body } = ht in match bs, goal with | _::_, None -> //if there are binders, we must have a goal fail g (Some st.range) "A renaming with binders must have a goal (with xs. rename ... in goal)" | _::_, Some goal -> //rewrite it as // with bs. assert goal; // rename [pairs] in goal; // ... let body = {st with term = Tm_ProofHintWithBinders { ht with binders = [] }} in { st with term = Tm_ProofHintWithBinders { hint_type=ASSERT { p = goal }; binders=bs; t=body } } | [], None -> // if there is no goal, take the goal to be the full current pre let lhs, rhs = rewrite_all g pairs pre in let t = { st with term = Tm_Rewrite { t1 = lhs; t2 = rhs } } in { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } | [], Some goal -> ( let goal, _ = PC.instantiate_term_implicits g goal in let lhs, rhs = rewrite_all g pairs goal in let t = { st with term = Tm_Rewrite { t1 = lhs; t2 = rhs } } in { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } )
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 297, "start_col": 0, "start_line": 262 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report" let rec open_binders (g:env) (bs:list binder) (uvs:env { disjoint uvs g }) (v:term) (body:st_term) : T.Tac (uvs:env { disjoint uvs g } & term & st_term) = match bs with | [] -> (| uvs, v, body |) | b::bs -> // these binders are only lax checked so far let _ = PC.check_universe (push_env g uvs) b.binder_ty in let x = fresh (push_env g uvs) in let ss = [ DT 0 (tm_var {nm_index=x;nm_ppname=b.binder_ppname}) ] in let bs = L.mapi (fun i b -> assume (i >= 0); subst_binder b (shift_subst_n i ss)) bs in let v = subst_term v (shift_subst_n (L.length bs) ss) in let body = subst_st_term body (shift_subst_n (L.length bs) ss) in open_binders g bs (push_binding uvs x b.binder_ppname b.binder_ty) v body let closing (bs:list (ppname & var & typ)) : subst = L.fold_right (fun (_, x, _) (n, ss) -> n+1, (ND x n)::ss ) bs (0, []) |> snd let rec close_binders (bs:list (ppname & var & typ)) : Tot (list binder) (decreases L.length bs) = match bs with | [] -> [] | (name, x, t)::bs -> let bss = L.mapi (fun n (n1, x1, t1) -> assume (n >= 0); n1, x1, subst_term t1 [ND x n]) bs in let b = mk_binder_ppname t name in assume (L.length bss == L.length bs); b::(close_binders bss) let unfold_defs (g:env) (defs:option (list string)) (t:term) : T.Tac term = let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> ( let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty ) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t)) let check_unfoldable g (v:term) : T.Tac unit = match v.t with | Tm_FStar _ -> () | _ -> fail g (Some v.range) (Printf.sprintf "`fold` and `unfold` expect a single user-defined predicate as an argument, \ but %s is a primitive term that cannot be folded or unfolded" (P.term_to_string v)) let visit_and_rewrite (p: (R.term & R.term)) (t:term) : T.Tac term = let open FStar.Reflection.V2.TermEq in let lhs, rhs = p in let visitor (t:R.term) : T.Tac R.term = if term_eq t lhs then rhs else t in match R.inspect_ln lhs with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in assume (is_host_term rhs); subst_term t [NT nv.uniq { t = Tm_FStar rhs; range = t.range }] ) | _ -> let rec aux (t:term) : T.Tac term = match t.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Inames | Tm_Unknown -> t | Tm_Inv i -> { t with t = Tm_Inv (aux i) } | Tm_AddInv i is -> { t with t = Tm_AddInv (aux i) (aux is) } | Tm_Pure p -> { t with t = Tm_Pure (aux p) } | Tm_Star l r -> { t with t = Tm_Star (aux l) (aux r) } | Tm_ExistsSL u b body -> { t with t = Tm_ExistsSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_ForallSL u b body -> { t with t = Tm_ForallSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_FStar h -> let h = FStar.Tactics.Visit.visit_tm visitor h in assume (is_host_term h); { t with t=Tm_FStar h } in aux t let visit_and_rewrite_conjuncts (p: (R.term & R.term)) (tms:list term) : T.Tac (list term) = T.map (visit_and_rewrite p) tms let visit_and_rewrite_conjuncts_all (p: list (R.term & R.term)) (goal:term) : T.Tac (term & term) = let tms = Pulse.Typing.Combinators.vprop_as_list goal in let tms' = T.fold_left (fun tms p -> visit_and_rewrite_conjuncts p tms) tms p in assume (L.length tms' == L.length tms); let lhs, rhs = T.fold_left2 (fun (lhs, rhs) t t' -> if eq_tm t t' then lhs, rhs else (t::lhs, t'::rhs)) ([], []) tms tms' in Pulse.Typing.Combinators.list_as_vprop lhs, Pulse.Typing.Combinators.list_as_vprop rhs let disjoint (dom:list var) (cod:Set.set var) = L.for_all (fun d -> not (Set.mem d cod)) dom let rec as_subst (p : list (term & term)) (out:list subst_elt) (domain:list var) (codomain:Set.set var) : option (list subst_elt) = match p with | [] -> if disjoint domain codomain then Some out else None | (e1, e2)::p -> ( match e1.t with | Tm_FStar e1 -> ( match R.inspect_ln e1 with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in as_subst p (NT nv.uniq e2::out) (nv.uniq ::domain ) (Set.union codomain (freevars e2)) ) | _ -> None ) | _ -> None ) let rewrite_all (g:env) (p: list (term & term)) (t:term) : T.Tac (term & term) = match as_subst p [] [] Set.empty with | Some s -> t, subst_term t s | _ -> let p : list (R.term & R.term) = T.map (fun (e1, e2) -> elab_term (fst (Pulse.Checker.Pure.instantiate_term_implicits g e1)), elab_term (fst (Pulse.Checker.Pure.instantiate_term_implicits g e2))) p in let lhs, rhs = visit_and_rewrite_conjuncts_all p t in debug_log g (fun _ -> Printf.sprintf "Rewrote %s to %s" (P.term_to_string lhs) (P.term_to_string rhs)); lhs, rhs
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> pre: Pulse.Syntax.Base.term -> st: Pulse.Syntax.Base.st_term { (match Mkst_term?.term st with | Pulse.Syntax.Base.Tm_ProofHintWithBinders { hint_type = Pulse.Syntax.Base.RENAME _ ; binders = _ ; t = _ } -> true | _ -> false) <: Type0 } -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Syntax.Base.proof_hint_type__RENAME__payload", "Prims.list", "Pulse.Syntax.Base.binder", "Prims.b2t", "Pulse.Syntax.Base.st_term'", "Pulse.Syntax.Base.st_term'__Tm_ProofHintWithBinders__payload", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Mktuple2", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.range", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.Tm_ProofHintWithBinders", "Pulse.Syntax.Base.Mkst_term'__Tm_ProofHintWithBinders__payload", "Pulse.Syntax.Base.ASSERT", "Pulse.Syntax.Base.Mkproof_hint_type__ASSERT__payload", "Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag", "Pulse.Syntax.Base.__proj__Mkst_term'__Tm_ProofHintWithBinders__payload__item__hint_type", "Prims.Nil", "Pulse.Syntax.Base.__proj__Mkst_term'__Tm_ProofHintWithBinders__payload__item__t", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Syntax.Base.as_binder", "Pulse.Typing.tm_unit", "Pulse.Syntax.Base.Tm_Rewrite", "Pulse.Syntax.Base.Mkst_term'__Tm_Rewrite__payload", "Pulse.Checker.AssertWithBinders.rewrite_all", "Pulse.Checker.Pure.instantiate_term_implicits" ]
[]
false
true
false
false
false
let check_renaming (g: env) (pre: term) (st: st_term { match st.term with | Tm_ProofHintWithBinders { hint_type = RENAME _ } -> true | _ -> false }) : T.Tac st_term =
let Tm_ProofHintWithBinders ht = st.term in let { hint_type = RENAME { pairs = pairs ; goal = goal } ; binders = bs ; t = body } = ht in match bs, goal with | _ :: _, None -> fail g (Some st.range) "A renaming with binders must have a goal (with xs. rename ... in goal)" | _ :: _, Some goal -> let body = { st with term = Tm_ProofHintWithBinders ({ ht with binders = [] }) } in { st with term = Tm_ProofHintWithBinders ({ hint_type = ASSERT ({ p = goal }); binders = bs; t = body }) } | [], None -> let lhs, rhs = rewrite_all g pairs pre in let t = { st with term = Tm_Rewrite ({ t1 = lhs; t2 = rhs }) } in { st with term = Tm_Bind ({ binder = as_binder tm_unit; head = t; body = body }) } | [], Some goal -> (let goal, _ = PC.instantiate_term_implicits g goal in let lhs, rhs = rewrite_all g pairs goal in let t = { st with term = Tm_Rewrite ({ t1 = lhs; t2 = rhs }) } in { st with term = Tm_Bind ({ binder = as_binder tm_unit; head = t; body = body }) })
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.sk_binder
val sk_binder : b: FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac (Prims.list FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding)
let sk_binder b = sk_binder' [] b
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 322, "start_col": 0, "start_line": 322 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac (Prims.list FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.sk_binder'", "Prims.Nil", "FStar.Pervasives.Native.tuple2", "Prims.list" ]
[]
false
true
false
false
false
let sk_binder b =
sk_binder' [] b
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.skolem
val skolem : _: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list (Prims.list FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding))
let skolem () = let bs = vars_of_env (cur_env ()) in map sk_binder bs
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 326, "start_col": 0, "start_line": 324 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list (Prims.list FStar.Tactics.NamedView.binding * FStar.Tactics.NamedView.binding))
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.Util.map", "FStar.Stubs.Reflection.V2.Data.binding", "FStar.Pervasives.Native.tuple2", "Prims.list", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Logic.sk_binder", "FStar.Stubs.Reflection.V2.Builtins.vars_of_env", "FStar.Stubs.Reflection.Types.env", "FStar.Tactics.V2.Derived.cur_env" ]
[]
false
true
false
false
false
let skolem () =
let bs = vars_of_env (cur_env ()) in map sk_binder bs
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.sk_binder'
val sk_binder' (acc: list binding) (b: binding) : Tac (list binding & binding)
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) = 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 *) )
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 318, "start_col": 0, "start_line": 308 }
(* 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.Stubs.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) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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)
FStar.Tactics.Effect.Tac
[]
[]
[ "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.Stubs.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.Stubs.Reflection.Types.term", "FStar.Tactics.V2.SyntaxCoercions.binding_to_term", "Prims.exn", "FStar.Pervasives.Native.Mktuple2" ]
[ "recursion" ]
false
true
false
false
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') with | _ -> (acc, b))
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.disjoint
val disjoint : dom: Prims.list Pulse.Syntax.Base.var -> cod: FStar.Set.set Pulse.Syntax.Base.var -> Prims.bool
let disjoint (dom:list var) (cod:Set.set var) = L.for_all (fun d -> not (Set.mem d cod)) dom
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 217, "start_col": 0, "start_line": 216 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report" let rec open_binders (g:env) (bs:list binder) (uvs:env { disjoint uvs g }) (v:term) (body:st_term) : T.Tac (uvs:env { disjoint uvs g } & term & st_term) = match bs with | [] -> (| uvs, v, body |) | b::bs -> // these binders are only lax checked so far let _ = PC.check_universe (push_env g uvs) b.binder_ty in let x = fresh (push_env g uvs) in let ss = [ DT 0 (tm_var {nm_index=x;nm_ppname=b.binder_ppname}) ] in let bs = L.mapi (fun i b -> assume (i >= 0); subst_binder b (shift_subst_n i ss)) bs in let v = subst_term v (shift_subst_n (L.length bs) ss) in let body = subst_st_term body (shift_subst_n (L.length bs) ss) in open_binders g bs (push_binding uvs x b.binder_ppname b.binder_ty) v body let closing (bs:list (ppname & var & typ)) : subst = L.fold_right (fun (_, x, _) (n, ss) -> n+1, (ND x n)::ss ) bs (0, []) |> snd let rec close_binders (bs:list (ppname & var & typ)) : Tot (list binder) (decreases L.length bs) = match bs with | [] -> [] | (name, x, t)::bs -> let bss = L.mapi (fun n (n1, x1, t1) -> assume (n >= 0); n1, x1, subst_term t1 [ND x n]) bs in let b = mk_binder_ppname t name in assume (L.length bss == L.length bs); b::(close_binders bss) let unfold_defs (g:env) (defs:option (list string)) (t:term) : T.Tac term = let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> ( let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty ) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t)) let check_unfoldable g (v:term) : T.Tac unit = match v.t with | Tm_FStar _ -> () | _ -> fail g (Some v.range) (Printf.sprintf "`fold` and `unfold` expect a single user-defined predicate as an argument, \ but %s is a primitive term that cannot be folded or unfolded" (P.term_to_string v)) let visit_and_rewrite (p: (R.term & R.term)) (t:term) : T.Tac term = let open FStar.Reflection.V2.TermEq in let lhs, rhs = p in let visitor (t:R.term) : T.Tac R.term = if term_eq t lhs then rhs else t in match R.inspect_ln lhs with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in assume (is_host_term rhs); subst_term t [NT nv.uniq { t = Tm_FStar rhs; range = t.range }] ) | _ -> let rec aux (t:term) : T.Tac term = match t.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Inames | Tm_Unknown -> t | Tm_Inv i -> { t with t = Tm_Inv (aux i) } | Tm_AddInv i is -> { t with t = Tm_AddInv (aux i) (aux is) } | Tm_Pure p -> { t with t = Tm_Pure (aux p) } | Tm_Star l r -> { t with t = Tm_Star (aux l) (aux r) } | Tm_ExistsSL u b body -> { t with t = Tm_ExistsSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_ForallSL u b body -> { t with t = Tm_ForallSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_FStar h -> let h = FStar.Tactics.Visit.visit_tm visitor h in assume (is_host_term h); { t with t=Tm_FStar h } in aux t let visit_and_rewrite_conjuncts (p: (R.term & R.term)) (tms:list term) : T.Tac (list term) = T.map (visit_and_rewrite p) tms let visit_and_rewrite_conjuncts_all (p: list (R.term & R.term)) (goal:term) : T.Tac (term & term) = let tms = Pulse.Typing.Combinators.vprop_as_list goal in let tms' = T.fold_left (fun tms p -> visit_and_rewrite_conjuncts p tms) tms p in assume (L.length tms' == L.length tms); let lhs, rhs = T.fold_left2 (fun (lhs, rhs) t t' -> if eq_tm t t' then lhs, rhs else (t::lhs, t'::rhs)) ([], []) tms tms' in Pulse.Typing.Combinators.list_as_vprop lhs, Pulse.Typing.Combinators.list_as_vprop rhs
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dom: Prims.list Pulse.Syntax.Base.var -> cod: FStar.Set.set Pulse.Syntax.Base.var -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Pulse.Syntax.Base.var", "FStar.Set.set", "FStar.List.Tot.Base.for_all", "Prims.op_Negation", "FStar.Set.mem", "Prims.bool" ]
[]
false
false
false
true
false
let disjoint (dom: list var) (cod: Set.set var) =
L.for_all (fun d -> not (Set.mem d cod)) dom
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.easy_fill
val easy_fill : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
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 ()
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 338, "start_col": 0, "start_line": 334 }
(* 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.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.smt", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V2.Data.binding", "FStar.Tactics.V2.Derived.trytac", "FStar.Stubs.Tactics.V2.Builtins.intro", "FStar.Tactics.V2.Derived.apply", "Prims.list", "FStar.Tactics.V2.Derived.repeat" ]
[]
false
true
false
false
false
let easy_fill () =
let _ = repeat intro in let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt ()
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.using_lemma
val using_lemma (t: term) : Tac binding
val using_lemma (t: term) : Tac binding
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"
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 378, "start_col": 0, "start_line": 374 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
FStar.Tactics.Effect.Tac
[]
[]
[ "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" ]
[]
false
true
false
false
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"
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.lem1_fa
val lem1_fa (#a #pre #post: _) ($lem: (x: a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x: a). pre x ==> post x)
val lem1_fa (#a #pre #post: _) ($lem: (x: a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x: a). pre x ==> post x)
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'
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 350, "start_col": 0, "start_line": 344 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (x: a -> FStar.Pervasives.Lemma (requires pre x) (ensures post x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). pre x ==> post x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_True", "FStar.Classical.move_requires", "Prims.l_Forall" ]
[]
false
false
true
false
false
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'
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.easy
val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a
val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a
let easy #a #x = x
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 341, "start_col": 0, "start_line": 341 }
(* 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.Stubs.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 ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let easy #a #x =
x
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.unfold_definition_and_simplify_eq
val unfold_definition_and_simplify_eq (tm: term) : Tac unit
val unfold_definition_and_simplify_eq (tm: term) : Tac unit
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
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 188, "start_col": 0, "start_line": 172 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tm: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Tactics.NamedView.term", "FStar.Stubs.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.Stubs.Tactics.V2.Builtins.clear_top", "FStar.Stubs.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.Stubs.Reflection.Types.typ", "FStar.Tactics.V2.Derived.cur_goal" ]
[ "recursion" ]
false
true
false
false
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 () | _ -> 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)
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.lem3_fa
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)
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) = 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'
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 368, "start_col": 0, "start_line": 362 }
(* 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.Stubs.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'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (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)
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
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'
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.simplify_eq_implication
val simplify_eq_implication: Prims.unit -> Tac unit
val simplify_eq_implication: Prims.unit -> Tac unit
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
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 167, "start_col": 0, "start_line": 156 }
(* 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.Stubs.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 | _ -> () ) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "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.Stubs.Tactics.V2.Builtins.clear_top", "FStar.Stubs.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.Stubs.Reflection.Types.typ", "FStar.Tactics.V2.Derived.cur_goal", "FStar.Stubs.Reflection.Types.env", "FStar.Tactics.V2.Derived.cur_env" ]
[ "recursion" ]
false
true
false
false
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 rewrite eq_h; clear_top (); visit simplify_eq_implication
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.lem2_fa
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)
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) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l'
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 359, "start_col": 0, "start_line": 353 }
(* 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.Stubs.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'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (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)
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
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'
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.vbind
val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q
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)
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 95, "end_line": 191, "start_col": 0, "start_line": 191 }
(* 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.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sq: Prims.squash p -> f: (_: p -> Prims.squash q) -> FStar.Pervasives.Lemma (ensures q)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "FStar.Classical.give_witness_from_squash", "FStar.Squash.bind_squash", "Prims.unit" ]
[]
true
false
true
false
false
let vbind #p #q sq f =
FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f)
false
HyE.RSA.fst
HyE.RSA.plainsize
val plainsize : Prims.int
let plainsize = aeadKeySize AES_128_GCM
{ "file_name": "examples/crypto/HyE.RSA.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 40, "start_col": 0, "start_line": 40 }
(* 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. *) (* our encryption module is parameterized by a "native" RSA-OAEP implementation, available at least for F#/.NET *) (* I am trying to capture functional correctness, which we did not have with F7; otherwise most refinements can be ignored. I think this would require coding "events" as membership of increasing mutable lists, possibly too advanced for a tutorial *) (* We should replace this module by an implementation using CoreCrypto, can we use OAEP? *) module HyE.RSA open FStar.List.Tot open Platform.Bytes open CoreCrypto module B = Platform.Bytes assume type pkey assume type skey
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Platform.Bytes.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "CoreCrypto.fst.checked" ], "interface_file": false, "source_file": "HyE.RSA.fst" }
[ { "abbrev": true, "full_module": "Platform.Bytes", "short_module": "B" }, { "abbrev": false, "full_module": "CoreCrypto", "short_module": null }, { "abbrev": false, "full_module": "Platform.Bytes", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "HyE", "short_module": null }, { "abbrev": false, "full_module": "HyE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[ "CoreCrypto.aeadKeySize", "CoreCrypto.AES_128_GCM" ]
[]
false
false
false
true
false
let plainsize =
aeadKeySize AES_128_GCM
false
FStar.Tactics.V2.Logic.fst
FStar.Tactics.V2.Logic.lemma_from_squash
val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (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 = let _ = f x in assert (b x)
{ "file_name": "ulib/FStar.Tactics.V2.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 331, "start_col": 0, "start_line": 331 }
(* 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.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.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" }
[ { "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.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (x: a -> Prims.squash (b x)) -> x: a -> FStar.Pervasives.Lemma (ensures b x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims._assert", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_from_squash #a #b f x =
let _ = f x in assert (b x)
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.unfold_defs
val unfold_defs (g: env) (defs: option (list string)) (t: term) : T.Tac term
val unfold_defs (g: env) (defs: option (list string)) (t: term) : T.Tac term
let unfold_defs (g:env) (defs:option (list string)) (t:term) : T.Tac term = let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> ( let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty ) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t))
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 89, "end_line": 149, "start_col": 0, "start_line": 126 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report" let rec open_binders (g:env) (bs:list binder) (uvs:env { disjoint uvs g }) (v:term) (body:st_term) : T.Tac (uvs:env { disjoint uvs g } & term & st_term) = match bs with | [] -> (| uvs, v, body |) | b::bs -> // these binders are only lax checked so far let _ = PC.check_universe (push_env g uvs) b.binder_ty in let x = fresh (push_env g uvs) in let ss = [ DT 0 (tm_var {nm_index=x;nm_ppname=b.binder_ppname}) ] in let bs = L.mapi (fun i b -> assume (i >= 0); subst_binder b (shift_subst_n i ss)) bs in let v = subst_term v (shift_subst_n (L.length bs) ss) in let body = subst_st_term body (shift_subst_n (L.length bs) ss) in open_binders g bs (push_binding uvs x b.binder_ppname b.binder_ty) v body let closing (bs:list (ppname & var & typ)) : subst = L.fold_right (fun (_, x, _) (n, ss) -> n+1, (ND x n)::ss ) bs (0, []) |> snd let rec close_binders (bs:list (ppname & var & typ)) : Tot (list binder) (decreases L.length bs) = match bs with | [] -> [] | (name, x, t)::bs -> let bss = L.mapi (fun n (n1, x1, t1) -> assume (n >= 0); n1, x1, subst_term t1 [ND x n]) bs in let b = mk_binder_ppname t name in assume (L.length bss == L.length bs); b::(close_binders bss)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> defs: FStar.Pervasives.Native.option (Prims.list Prims.string) -> t: Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.term
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "FStar.Pervasives.Native.option", "Prims.list", "Prims.string", "Pulse.Syntax.Base.term", "FStar.Tactics.NamedView.term", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "Prims.unit", "Pulse.Checker.AssertWithBinders.debug_log", "FStar.Printf.sprintf", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "Pulse.Syntax.Printer.term_to_string", "Prims.eq2", "FStar.Stubs.Reflection.Types.term", "Pulse.Elaborate.Pure.elab_term", "Pulse.Checker.AssertWithBinders.option_must", "Pulse.Readback.readback_ty", "Pulse.RuntimeUtils.unfold_def", "Pulse.Typing.Env.fstar_env", "Prims.Nil", "FStar.String.concat", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.V2.Data.term_view", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.range", "Pulse.RuntimeUtils.range_of_term", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V2.SyntaxHelpers.collect_app" ]
[]
false
true
false
false
false
let unfold_defs (g: env) (defs: option (list string)) (t: term) : T.Tac term =
let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> (let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t))
false
Hacl.Spec.Bignum.ModReduction.fst
Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp
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
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
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModReduction.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 33, "start_col": 0, "start_line": 30 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: 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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Bignum.ModReduction.fst
Hacl.Spec.Bignum.ModReduction.bn_mod_slow
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)
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 = 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
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModReduction.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 98, "start_col": 0, "start_line": 95 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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)
Prims.Pure
[]
[]
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Spec.Bignum.ModReduction.fst
Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp_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)
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)
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModReduction.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 79, "start_col": 0, "start_line": 48 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: 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)
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
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)
false
OWGCounter.fst
OWGCounter.og_acquire
val og_acquire (r: ref int) (r_mine r_other: ghost_ref int) (b: G.erased bool) (l: lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit emp (fun _ -> lock_inv r r_mine r_other)
val og_acquire (r: ref int) (r_mine r_other: ghost_ref int) (b: G.erased bool) (l: lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit emp (fun _ -> lock_inv r r_mine r_other)
let og_acquire (r:ref int) (r_mine r_other:ghost_ref int) (b:G.erased bool) (l:lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit emp (fun _ -> lock_inv r r_mine r_other) = acquire l; if b then begin rewrite_slprop (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (lock_inv r r_mine r_other) (fun _ -> ()); () end else begin rewrite_slprop (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (lock_inv r r_other r_mine) (fun _ -> ()); lock_inv_equiv_lemma r r_other r_mine; rewrite_slprop (lock_inv r r_other r_mine) (lock_inv r r_mine r_other) (fun _ -> reveal_equiv (lock_inv r r_other r_mine) (lock_inv r r_mine r_other)) end
{ "file_name": "share/steel/examples/steel/OWGCounter.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 7, "end_line": 149, "start_col": 0, "start_line": 128 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* * An implementation of the parallel counter presented by Owicki and Gries * "Verifying properties of parallel programs: An axiomatic approach.", CACM'76 * * In this example, the main thread forks two worker thread that both * increment a shared counter. The goal of the example is to show that * after both the worker threads are done, the value of the counter is * its original value + 2. * * See http://pm.inf.ethz.ch/publications/getpdf.php for an implementation * of the OWG counters in the Chalice framework. *) module OWGCounter module G = FStar.Ghost open Steel.Memory open Steel.FractionalPermission open Steel.Reference open Steel.SpinLock open Steel.Effect.Atomic open Steel.Effect module R = Steel.Reference module P = Steel.FractionalPermission module A = Steel.Effect.Atomic #set-options "--ide_id_info_off --using_facts_from '* -FStar.Tactics -FStar.Reflection' --fuel 0 --ifuel 0" let half_perm = half_perm full_perm (* Some basic wrappers to avoid issues with normalization. TODO: The frame inference tactic should not normalize fst and snd*) noextract let fst = fst noextract let snd = snd /// The core invariant of the Owicki-Gries counter, shared by the two parties. /// The concrete counter [r] is shared, and the full permission is stored in the invariant. /// Each party also has half permission to their own ghost counter [r1] or [r2], ensuring that /// only them can modify it by retrieving the other half of the permission when accessing the invariant. /// The `__reduce__` attribute indicates the frame inference tactic to unfold this predicate for frame inference only [@@ __reduce__] let lock_inv_slprop (r:ref int) (r1 r2:ghost_ref int) (w:int & int) = ghost_pts_to r1 half_perm (fst w) `star` ghost_pts_to r2 half_perm (snd w) `star` pts_to r full_perm (fst w + snd w) [@@ __reduce__] let lock_inv_pred (r:ref int) (r1 r2:ghost_ref int) = fun (x:int & int) -> lock_inv_slprop r r1 r2 x /// The actual invariant, existentially quantifying over the values currently stored in the two ghost references [@@ __reduce__] let lock_inv (r:ref int) (r1 r2:ghost_ref int) : vprop = h_exists (lock_inv_pred r r1 r2) #push-options "--warn_error -271 --fuel 1 --ifuel 1" /// A helper lemma to reason about the lock invariant let lock_inv_equiv_lemma (r:ref int) (r1 r2:ghost_ref int) : Lemma (lock_inv r r1 r2 `equiv` lock_inv r r2 r1) = let aux (r:ref int) (r1 r2:ghost_ref int) (m:mem) : Lemma (requires interp (hp_of (lock_inv r r1 r2)) m) (ensures interp (hp_of (lock_inv r r2 r1)) m) [SMTPat ()] = assert ( Steel.Memory.h_exists #(int & int) (fun x -> hp_of (lock_inv_pred r r1 r2 x)) == h_exists_sl #(int & int) (lock_inv_pred r r1 r2)) by (FStar.Tactics.norm [delta_only [`%h_exists_sl]]); let w : G.erased (int & int) = id_elim_exists (fun x -> hp_of (lock_inv_pred r r1 r2 x)) m in assert ((ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))) `equiv` (ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w)))) by (FStar.Tactics.norm [delta_attr [`%__steel_reduce__]]; canon' false (`true_p) (`true_p)); reveal_equiv (ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))) (ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))); assert (interp (hp_of (lock_inv_pred r r2 r1 (snd w, fst w))) m); intro_h_exists (snd w, fst w) (fun x -> hp_of (lock_inv_pred r r2 r1 x)) m; assert (interp (Steel.Memory.h_exists (fun x -> hp_of (lock_inv_pred r r2 r1 x))) m); assert ( Steel.Memory.h_exists #(int & int) (fun x -> hp_of (lock_inv_pred r r2 r1 x)) == h_exists_sl #(int & int) (lock_inv_pred r r2 r1)) by (FStar.Tactics.norm [delta_only [`%h_exists_sl]]) in reveal_equiv (lock_inv r r1 r2) (lock_inv r r2 r1) #pop-options /// Acquiring the shared lock invariant
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "OWGCounter.fst" }
[ { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.Reference.ref Prims.int -> r_mine: Steel.Reference.ghost_ref Prims.int -> r_other: Steel.Reference.ghost_ref Prims.int -> b: FStar.Ghost.erased Prims.bool -> l: Steel.SpinLock.lock (OWGCounter.lock_inv r (match FStar.Ghost.reveal b with | true -> r_mine | _ -> r_other) (match FStar.Ghost.reveal b with | true -> r_other | _ -> r_mine)) -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Reference.ref", "Prims.int", "Steel.Reference.ghost_ref", "FStar.Ghost.erased", "Prims.bool", "Steel.SpinLock.lock", "OWGCounter.lock_inv", "FStar.Ghost.reveal", "Prims.unit", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Memory.mem", "Steel.Effect.Common.reveal_equiv", "OWGCounter.lock_inv_equiv_lemma", "Steel.SpinLock.acquire", "Steel.Effect.Common.emp", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let og_acquire (r: ref int) (r_mine r_other: ghost_ref int) (b: G.erased bool) (l: lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit emp (fun _ -> lock_inv r r_mine r_other) =
acquire l; if b then (rewrite_slprop (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (lock_inv r r_mine r_other) (fun _ -> ()); ()) else (rewrite_slprop (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (lock_inv r r_other r_mine) (fun _ -> ()); lock_inv_equiv_lemma r r_other r_mine; rewrite_slprop (lock_inv r r_other r_mine) (lock_inv r r_mine r_other) (fun _ -> reveal_equiv (lock_inv r r_other r_mine) (lock_inv r r_mine r_other)))
false
Spec.Poly1305.fst
Spec.Poly1305.prime
val prime:pos
val prime:pos
let prime : pos = let p = pow2 130 - 5 in assert_norm (p > 0); p
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 17, "start_col": 0, "start_line": 14 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Prims.pos
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_GreaterThan", "Prims.int", "Prims.op_Subtraction", "Prims.pow2" ]
[]
false
false
false
true
false
let prime:pos =
let p = pow2 130 - 5 in assert_norm (p > 0); p
false
Spec.Poly1305.fst
Spec.Poly1305.felem
val felem : Type0
let felem = x:nat{x < prime}
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 19, "start_col": 0, "start_line": 19 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Spec.Poly1305.prime" ]
[]
false
false
false
true
true
let felem =
x: nat{x < prime}
false
Spec.Poly1305.fst
Spec.Poly1305.from_felem
val from_felem (x: felem) : nat
val from_felem (x: felem) : nat
let from_felem (x:felem) : nat = x
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 24, "start_col": 0, "start_line": 24 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
x: Spec.Poly1305.felem -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Spec.Poly1305.felem", "Prims.nat" ]
[]
false
false
false
true
false
let from_felem (x: felem) : nat =
x
false
Spec.Poly1305.fst
Spec.Poly1305.to_felem
val to_felem (x: nat{x < prime}) : felem
val to_felem (x: nat{x < prime}) : felem
let to_felem (x:nat{x < prime}) : felem = x
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 23, "start_col": 0, "start_line": 23 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
x: Prims.nat{x < Spec.Poly1305.prime} -> Spec.Poly1305.felem
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Spec.Poly1305.prime", "Spec.Poly1305.felem" ]
[]
false
false
false
false
false
let to_felem (x: nat{x < prime}) : felem =
x
false
OWGCounter.fst
OWGCounter.og_release
val og_release (r: ref int) (r_mine r_other: ghost_ref int) (b: G.erased bool) (l: lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit (lock_inv r r_mine r_other) (fun _ -> emp)
val og_release (r: ref int) (r_mine r_other: ghost_ref int) (b: G.erased bool) (l: lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit (lock_inv r r_mine r_other) (fun _ -> emp)
let og_release (r:ref int) (r_mine r_other:ghost_ref int) (b:G.erased bool) (l:lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit (lock_inv r r_mine r_other) (fun _ -> emp) = if b then begin rewrite_slprop (lock_inv r r_mine r_other) (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (fun _ -> ()); () end else begin lock_inv_equiv_lemma r r_mine r_other; rewrite_slprop (lock_inv r r_mine r_other) (lock_inv r r_other r_mine) (fun _ -> reveal_equiv (lock_inv r r_mine r_other) (lock_inv r r_other r_mine)); rewrite_slprop (lock_inv r r_other r_mine) (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (fun _ -> ()) end; release l
{ "file_name": "share/steel/examples/steel/OWGCounter.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 174, "start_col": 0, "start_line": 153 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* * An implementation of the parallel counter presented by Owicki and Gries * "Verifying properties of parallel programs: An axiomatic approach.", CACM'76 * * In this example, the main thread forks two worker thread that both * increment a shared counter. The goal of the example is to show that * after both the worker threads are done, the value of the counter is * its original value + 2. * * See http://pm.inf.ethz.ch/publications/getpdf.php for an implementation * of the OWG counters in the Chalice framework. *) module OWGCounter module G = FStar.Ghost open Steel.Memory open Steel.FractionalPermission open Steel.Reference open Steel.SpinLock open Steel.Effect.Atomic open Steel.Effect module R = Steel.Reference module P = Steel.FractionalPermission module A = Steel.Effect.Atomic #set-options "--ide_id_info_off --using_facts_from '* -FStar.Tactics -FStar.Reflection' --fuel 0 --ifuel 0" let half_perm = half_perm full_perm (* Some basic wrappers to avoid issues with normalization. TODO: The frame inference tactic should not normalize fst and snd*) noextract let fst = fst noextract let snd = snd /// The core invariant of the Owicki-Gries counter, shared by the two parties. /// The concrete counter [r] is shared, and the full permission is stored in the invariant. /// Each party also has half permission to their own ghost counter [r1] or [r2], ensuring that /// only them can modify it by retrieving the other half of the permission when accessing the invariant. /// The `__reduce__` attribute indicates the frame inference tactic to unfold this predicate for frame inference only [@@ __reduce__] let lock_inv_slprop (r:ref int) (r1 r2:ghost_ref int) (w:int & int) = ghost_pts_to r1 half_perm (fst w) `star` ghost_pts_to r2 half_perm (snd w) `star` pts_to r full_perm (fst w + snd w) [@@ __reduce__] let lock_inv_pred (r:ref int) (r1 r2:ghost_ref int) = fun (x:int & int) -> lock_inv_slprop r r1 r2 x /// The actual invariant, existentially quantifying over the values currently stored in the two ghost references [@@ __reduce__] let lock_inv (r:ref int) (r1 r2:ghost_ref int) : vprop = h_exists (lock_inv_pred r r1 r2) #push-options "--warn_error -271 --fuel 1 --ifuel 1" /// A helper lemma to reason about the lock invariant let lock_inv_equiv_lemma (r:ref int) (r1 r2:ghost_ref int) : Lemma (lock_inv r r1 r2 `equiv` lock_inv r r2 r1) = let aux (r:ref int) (r1 r2:ghost_ref int) (m:mem) : Lemma (requires interp (hp_of (lock_inv r r1 r2)) m) (ensures interp (hp_of (lock_inv r r2 r1)) m) [SMTPat ()] = assert ( Steel.Memory.h_exists #(int & int) (fun x -> hp_of (lock_inv_pred r r1 r2 x)) == h_exists_sl #(int & int) (lock_inv_pred r r1 r2)) by (FStar.Tactics.norm [delta_only [`%h_exists_sl]]); let w : G.erased (int & int) = id_elim_exists (fun x -> hp_of (lock_inv_pred r r1 r2 x)) m in assert ((ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))) `equiv` (ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w)))) by (FStar.Tactics.norm [delta_attr [`%__steel_reduce__]]; canon' false (`true_p) (`true_p)); reveal_equiv (ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))) (ghost_pts_to r2 half_perm (fst (snd w, fst w)) `star` ghost_pts_to r1 half_perm (snd (snd w, fst w)) `star` pts_to r full_perm (fst (snd w, fst w) + snd (snd w, fst w))); assert (interp (hp_of (lock_inv_pred r r2 r1 (snd w, fst w))) m); intro_h_exists (snd w, fst w) (fun x -> hp_of (lock_inv_pred r r2 r1 x)) m; assert (interp (Steel.Memory.h_exists (fun x -> hp_of (lock_inv_pred r r2 r1 x))) m); assert ( Steel.Memory.h_exists #(int & int) (fun x -> hp_of (lock_inv_pred r r2 r1 x)) == h_exists_sl #(int & int) (lock_inv_pred r r2 r1)) by (FStar.Tactics.norm [delta_only [`%h_exists_sl]]) in reveal_equiv (lock_inv r r1 r2) (lock_inv r r2 r1) #pop-options /// Acquiring the shared lock invariant inline_for_extraction noextract let og_acquire (r:ref int) (r_mine r_other:ghost_ref int) (b:G.erased bool) (l:lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit emp (fun _ -> lock_inv r r_mine r_other) = acquire l; if b then begin rewrite_slprop (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (lock_inv r r_mine r_other) (fun _ -> ()); () end else begin rewrite_slprop (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (lock_inv r r_other r_mine) (fun _ -> ()); lock_inv_equiv_lemma r r_other r_mine; rewrite_slprop (lock_inv r r_other r_mine) (lock_inv r r_mine r_other) (fun _ -> reveal_equiv (lock_inv r r_other r_mine) (lock_inv r r_mine r_other)) end /// Releasing the shared lock invariant
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "OWGCounter.fst" }
[ { "abbrev": true, "full_module": "Steel.Effect.Atomic", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.SpinLock", "short_module": null }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.Reference.ref Prims.int -> r_mine: Steel.Reference.ghost_ref Prims.int -> r_other: Steel.Reference.ghost_ref Prims.int -> b: FStar.Ghost.erased Prims.bool -> l: Steel.SpinLock.lock (OWGCounter.lock_inv r (match FStar.Ghost.reveal b with | true -> r_mine | _ -> r_other) (match FStar.Ghost.reveal b with | true -> r_other | _ -> r_mine)) -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Reference.ref", "Prims.int", "Steel.Reference.ghost_ref", "FStar.Ghost.erased", "Prims.bool", "Steel.SpinLock.lock", "OWGCounter.lock_inv", "FStar.Ghost.reveal", "Steel.SpinLock.release", "Prims.unit", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Memory.mem", "Steel.Effect.Common.reveal_equiv", "OWGCounter.lock_inv_equiv_lemma", "Steel.Effect.Common.emp", "Steel.Effect.Common.vprop" ]
[]
false
true
false
false
false
let og_release (r: ref int) (r_mine r_other: ghost_ref int) (b: G.erased bool) (l: lock (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine))) : SteelT unit (lock_inv r r_mine r_other) (fun _ -> emp) =
if b then (rewrite_slprop (lock_inv r r_mine r_other) (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (fun _ -> ()); ()) else (lock_inv_equiv_lemma r r_mine r_other; rewrite_slprop (lock_inv r r_mine r_other) (lock_inv r r_other r_mine) (fun _ -> reveal_equiv (lock_inv r r_mine r_other) (lock_inv r r_other r_mine)); rewrite_slprop (lock_inv r r_other r_mine) (lock_inv r (if b then r_mine else r_other) (if b then r_other else r_mine)) (fun _ -> ())); release l
false
Spec.Poly1305.fst
Spec.Poly1305.fadd
val fadd (x y: felem) : felem
val fadd (x y: felem) : felem
let fadd (x:felem) (y:felem) : felem = (x + y) % prime
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 20, "start_col": 0, "start_line": 20 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
x: Spec.Poly1305.felem -> y: Spec.Poly1305.felem -> Spec.Poly1305.felem
Prims.Tot
[ "total" ]
[]
[ "Spec.Poly1305.felem", "Prims.op_Modulus", "Prims.op_Addition", "Spec.Poly1305.prime" ]
[]
false
false
false
true
false
let fadd (x y: felem) : felem =
(x + y) % prime
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_update1
val poly1305_update1 (r: felem) (len: size_nat{len <= size_block}) (b: lbytes len) (acc: felem) : Tot felem
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 = (encode len b `fadd` acc) `fmul` r
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 57, "start_col": 0, "start_line": 56 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Impl.K256.Verify.fst
Hacl.Impl.K256.Verify.ecdsa_verify_cmpr
val ecdsa_verify_cmpr: r:QA.qelem -> pk:point -> u1:QA.qelem -> u2:QA.qelem -> Stack bool (requires fun h -> live h r /\ live h pk /\ live h u1 /\ live h u2 /\ disjoint r u1 /\ disjoint r u2 /\ disjoint r pk /\ disjoint pk u1 /\ disjoint pk u2 /\ point_inv h pk /\ QA.qas_nat h u1 < S.q /\ QA.qas_nat h u2 < S.q /\ 0 < QA.qas_nat h r /\ QA.qas_nat h r < S.q) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let _X, _Y, _Z = S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk) in b <==> (if S.is_proj_point_at_inf (_X, _Y, _Z) then false else S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r)))
val ecdsa_verify_cmpr: r:QA.qelem -> pk:point -> u1:QA.qelem -> u2:QA.qelem -> Stack bool (requires fun h -> live h r /\ live h pk /\ live h u1 /\ live h u2 /\ disjoint r u1 /\ disjoint r u2 /\ disjoint r pk /\ disjoint pk u1 /\ disjoint pk u2 /\ point_inv h pk /\ QA.qas_nat h u1 < S.q /\ QA.qas_nat h u2 < S.q /\ 0 < QA.qas_nat h r /\ QA.qas_nat h r < S.q) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let _X, _Y, _Z = S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk) in b <==> (if S.is_proj_point_at_inf (_X, _Y, _Z) then false else S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r)))
let ecdsa_verify_cmpr r pk u1 u2 = push_frame (); let res = create_point () in let h0 = ST.get () in point_mul_g_double_split_lambda_vartime res u1 u2 pk; let h1 = ST.get () in assert (S.to_aff_point (point_eval h1 res) == S.to_aff_point (S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk))); KL.lemma_aff_is_point_at_inf (point_eval h1 res); KL.lemma_aff_is_point_at_inf (S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk)); let b = if is_proj_point_at_inf_vartime res then false else ecdsa_verify_avoid_finv res r in pop_frame (); b
{ "file_name": "code/k256/Hacl.Impl.K256.Verify.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 169, "start_col": 0, "start_line": 151 }
module Hacl.Impl.K256.Verify open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module S = Spec.K256 module KL = Spec.K256.Lemmas open Hacl.K256.Field open Hacl.Impl.K256.Point open Hacl.Impl.K256.PointMul open Hacl.Impl.K256.GLV module QA = Hacl.K256.Scalar module QI = Hacl.Impl.K256.Qinv module BL = Hacl.Spec.K256.Field52.Lemmas module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_verify_get_u12 (u1 u2 r s z: QA.qelem) : Stack unit (requires fun h -> live h r /\ live h s /\ live h z /\ live h u1 /\ live h u2 /\ disjoint u1 u2 /\ disjoint u1 z /\ disjoint u1 r /\ disjoint u1 s /\ disjoint u2 z /\ disjoint u2 r /\ disjoint u2 s /\ QA.qas_nat h s < S.q /\ QA.qas_nat h z < S.q /\ QA.qas_nat h r < S.q) (ensures fun h0 _ h1 -> modifies (loc u1 |+| loc u2) h0 h1 /\ (let sinv = S.qinv (QA.qas_nat h0 s) in QA.qas_nat h1 u1 == QA.qas_nat h0 z * sinv % S.q /\ QA.qas_nat h1 u2 == QA.qas_nat h0 r * sinv % S.q)) let ecdsa_verify_get_u12 u1 u2 r s z = push_frame (); let sinv = QA.create_qelem () in QI.qinv sinv s; QA.qmul u1 z sinv; QA.qmul u2 r sinv; pop_frame () val fmul_eq_vartime (r z x: felem) : Stack bool (requires fun h -> live h r /\ live h z /\ live h x /\ eq_or_disjoint r z /\ felem_fits5 (as_felem5 h r) (2,2,2,2,2) /\ as_nat h r < S.prime /\ inv_lazy_reduced2 h z /\ inv_fully_reduced h x) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (S.fmul (as_nat h0 r) (feval h0 z) = as_nat h0 x)) [@CInline] let fmul_eq_vartime r z x = push_frame (); let tmp = create_felem () in fmul tmp r z; let h1 = ST.get () in fnormalize tmp tmp; let h2 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (as_felem5 h1 tmp); assert (inv_fully_reduced h2 tmp); let b = is_felem_eq_vartime tmp x in pop_frame (); b inline_for_extraction noextract val ecdsa_verify_avoid_finv: p:point -> r:QA.qelem -> Stack bool (requires fun h -> live h p /\ live h r /\ disjoint p r /\ point_inv h p /\ QA.qe_lt_q h r /\ 0 < QA.qas_nat h r /\ not (S.is_proj_point_at_inf (point_eval h p))) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let (_X, _Y, _Z) = point_eval h0 p in b <==> (S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r))) let ecdsa_verify_avoid_finv p r = let h0 = ST.get () in let x, y, z = getx p, gety p, getz p in push_frame (); let r_bytes = create 32ul (u8 0) in let r_fe = create_felem () in let tmp_q = create_felem () in let tmp_x = create_felem () in QA.store_qelem r_bytes r; load_felem r_fe r_bytes; let h1 = ST.get () in assert (modifies (loc r_fe) h0 h1); //assert (inv_fully_reduced h1 r_fe); //assert (as_nat h1 r_fe == qas_nat h1 r); let h2 = ST.get () in fnormalize tmp_x x; let h3 = ST.get () in assert (modifies (loc tmp_x) h2 h3); BL.normalize5_lemma (1,1,1,1,2) (as_felem5 h2 x); //assert (inv_fully_reduced h3 tmp_x); //assert (inv_lazy_reduced2 h3 z); let is_rz_x = fmul_eq_vartime r_fe z tmp_x in //assert (is_rz_x == (S.fmul (as_nat h3 r_fe) (feval h3 z) = as_nat h3 tmp_x)); let res : bool = if not is_rz_x then begin let is_r_lt_p_m_q = is_felem_lt_prime_minus_order_vartime r_fe in if is_r_lt_p_m_q then begin assert (as_nat h1 r_fe < S.prime - S.q); make_u52_5 tmp_q (make_order_k256 ()); let h4 = ST.get () in BL.add5_lemma (1,1,1,1,1) (1,1,1,1,1) (as_felem5 h4 r_fe) (as_felem5 h4 tmp_q); fadd tmp_q r_fe tmp_q; fmul_eq_vartime tmp_q z tmp_x end //assert (is_rqz_x == (S.fmul (feval h5 tmp) (feval h5 z) = as_nat h5 tmp_x)); else false end else true in let h4 = ST.get () in assert (modifies (loc tmp_q) h3 h4); pop_frame (); KL.ecdsa_verify_avoid_finv (point_eval h0 p) (QA.qas_nat h0 r); assert (res <==> (S.fmul (feval h0 x) (S.finv (feval h0 z)) % S.q = QA.qas_nat h0 r)); let h5 = ST.get () in assert (modifies0 h0 h5); res inline_for_extraction noextract val ecdsa_verify_cmpr: r:QA.qelem -> pk:point -> u1:QA.qelem -> u2:QA.qelem -> Stack bool (requires fun h -> live h r /\ live h pk /\ live h u1 /\ live h u2 /\ disjoint r u1 /\ disjoint r u2 /\ disjoint r pk /\ disjoint pk u1 /\ disjoint pk u2 /\ point_inv h pk /\ QA.qas_nat h u1 < S.q /\ QA.qas_nat h u2 < S.q /\ 0 < QA.qas_nat h r /\ QA.qas_nat h r < S.q) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let _X, _Y, _Z = S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk) in b <==> (if S.is_proj_point_at_inf (_X, _Y, _Z) then false else S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.Qinv.fst.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.GLV.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.K256.Verify.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "QA" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Field", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Hacl.K256.Scalar.qelem -> pk: Hacl.Impl.K256.Point.point -> u1: Hacl.K256.Scalar.qelem -> u2: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Hacl.Impl.K256.Point.point", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.K256.Verify.ecdsa_verify_avoid_finv", "Hacl.Impl.K256.Point.is_proj_point_at_inf_vartime", "Spec.K256.Lemmas.lemma_aff_is_point_at_inf", "Spec.K256.point_mul_double_g", "Hacl.K256.Scalar.qas_nat", "Hacl.Impl.K256.Point.point_eval", "Prims._assert", "Prims.eq2", "Spec.K256.PointOps.aff_point", "Spec.K256.PointOps.to_aff_point", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.K256.GLV.point_mul_g_double_split_lambda_vartime", "Hacl.Impl.K256.Point.create_point", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let ecdsa_verify_cmpr r pk u1 u2 =
push_frame (); let res = create_point () in let h0 = ST.get () in point_mul_g_double_split_lambda_vartime res u1 u2 pk; let h1 = ST.get () in assert (S.to_aff_point (point_eval h1 res) == S.to_aff_point (S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk))); KL.lemma_aff_is_point_at_inf (point_eval h1 res); KL.lemma_aff_is_point_at_inf (S.point_mul_double_g (QA.qas_nat h0 u1) (QA.qas_nat h0 u2) (point_eval h0 pk)); let b = if is_proj_point_at_inf_vartime res then false else ecdsa_verify_avoid_finv res r in pop_frame (); b
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_mac
val poly1305_mac (msg: bytes) (k: key) : Tot tag
val poly1305_mac (msg: bytes) (k: key) : Tot tag
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
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 77, "start_col": 0, "start_line": 74 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
msg: Lib.ByteSequence.bytes -> k: Spec.Poly1305.key -> Spec.Poly1305.tag
Prims.Tot
[ "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" ]
[]
false
false
false
true
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
false
Spec.Poly1305.fst
Spec.Poly1305.zero
val zero:felem
val zero:felem
let zero : felem = to_felem 0
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 25, "start_col": 0, "start_line": 25 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Spec.Poly1305.felem
Prims.Tot
[ "total" ]
[]
[ "Spec.Poly1305.to_felem" ]
[]
false
false
false
true
false
let zero:felem =
to_felem 0
false
Spec.Poly1305.fst
Spec.Poly1305.fmul
val fmul (x y: felem) : felem
val fmul (x y: felem) : felem
let fmul (x:felem) (y:felem) : felem = (x * y) % prime
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 21, "start_col": 0, "start_line": 21 }
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}
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
x: Spec.Poly1305.felem -> y: Spec.Poly1305.felem -> Spec.Poly1305.felem
Prims.Tot
[ "total" ]
[]
[ "Spec.Poly1305.felem", "Prims.op_Modulus", "FStar.Mul.op_Star", "Spec.Poly1305.prime" ]
[]
false
false
false
true
false
let fmul (x y: felem) : felem =
(x * y) % prime
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_init
val poly1305_init (k: key) : Tot (felem & felem)
val poly1305_init (k: key) : Tot (felem & felem)
let poly1305_init (k:key) : Tot (felem & felem) = let r = poly1305_encode_r (slice k 0 16) in zero, r
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 49, "start_col": 0, "start_line": 47 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Spec.Poly1305.key -> Spec.Poly1305.felem * Spec.Poly1305.felem
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let poly1305_init (k: key) : Tot (felem & felem) =
let r = poly1305_encode_r (slice k 0 16) in zero, r
false
Spec.Poly1305.fst
Spec.Poly1305.size_key
val size_key:size_nat
val size_key:size_nat
let size_key : size_nat = 32
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 29, "start_col": 0, "start_line": 29 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
n: Prims.nat{n <= Prims.pow2 32 - 1}
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
false
false
let size_key:size_nat =
32
false
FStar.Classical.fst
FStar.Classical.lemma_to_squash_gtot
val lemma_to_squash_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> Lemma (p x))) (x: a) : GTot (squash (p x))
val lemma_to_squash_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> Lemma (p x))) (x: a) : GTot (squash (p x))
let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x)
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 27, "start_col": 0, "start_line": 25 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> FStar.Pervasives.Lemma (ensures p x)) -> x: a -> Prims.GTot (Prims.squash (p x))
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Squash.get_proof" ]
[]
false
false
true
false
false
let lemma_to_squash_gtot #a #p f x =
f x; get_proof (p x)
false
Spec.Poly1305.fst
Spec.Poly1305.size_block
val size_block:size_nat
val size_block:size_nat
let size_block : size_nat = 16
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 28, "start_col": 0, "start_line": 28 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
n: Prims.nat{n <= Prims.pow2 32 - 1}
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
false
false
let size_block:size_nat =
16
false
FStar.Classical.fst
FStar.Classical.arrow_to_impl
val arrow_to_impl (#a #b: Type0) (_: (squash a -> GTot (squash b))) : GTot (a ==> b)
val arrow_to_impl (#a #b: Type0) (_: (squash a -> GTot (squash b))) : GTot (a ==> b)
let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x)))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 94, "end_line": 43, "start_col": 0, "start_line": 43 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.squash a -> Prims.GTot (Prims.squash b)) -> Prims.GTot (a ==> b)
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.squash", "FStar.Squash.squash_double_arrow", "FStar.Squash.return_squash", "Prims.l_imp" ]
[]
false
false
false
false
false
let arrow_to_impl #a #b f =
squash_double_arrow (return_squash (fun x -> f (return_squash x)))
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_encode_r
val poly1305_encode_r (rb: block) : Tot felem
val poly1305_encode_r (rb: block) : Tot felem
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)
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 45, "start_col": 0, "start_line": 37 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
rb: Spec.Poly1305.block -> Spec.Poly1305.felem
Prims.Tot
[ "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" ]
[]
false
false
false
true
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)
false
FStar.Classical.fst
FStar.Classical.impl_to_arrow
val impl_to_arrow (#a #b: Type0) (_: (a ==> b)) (_: squash a) : Tot (squash b)
val impl_to_arrow (#a #b: Type0) (_: (a ==> b)) (_: squash a) : Tot (squash b)
let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x)))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 90, "end_line": 41, "start_col": 0, "start_line": 40 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
impl: (a ==> b) -> sx: Prims.squash a -> Prims.squash b
Prims.Tot
[ "total" ]
[]
[ "Prims.l_imp", "Prims.squash", "FStar.Squash.bind_squash", "FStar.Squash.return_squash" ]
[]
false
false
true
true
false
let impl_to_arrow #a #b impl sx =
bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x)))
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_finish
val poly1305_finish (k: key) (acc: felem) : Tot tag
val poly1305_finish (k: key) (acc: felem) : Tot tag
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
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 62, "start_col": 0, "start_line": 59 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
k: Spec.Poly1305.key -> acc: Spec.Poly1305.felem -> Spec.Poly1305.tag
Prims.Tot
[ "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" ]
[]
false
false
false
true
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
false
FStar.Classical.fst
FStar.Classical.impl_intro_tot
val impl_intro_tot (#p #q: Type0) ($_: (p -> Tot q)) : Tot (p ==> q)
val impl_intro_tot (#p #q: Type0) ($_: (p -> Tot q)) : Tot (p ==> q)
let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 47, "start_col": 0, "start_line": 47 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (_: p -> q) -> (p ==> q)
Prims.Tot
[ "total" ]
[]
[ "FStar.Squash.return_squash", "Prims.l_imp" ]
[]
false
false
false
true
false
let impl_intro_tot #p #q f =
return_squash #(p -> GTot q) f
false
FStar.Classical.fst
FStar.Classical.get_squashed
val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True))
val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True))
let get_squashed #b a = let p = get_proof a in join_squash #b p
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 35, "start_col": 0, "start_line": 33 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": true, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type0 -> Prims.Pure a
Prims.Pure
[]
[]
[ "FStar.Squash.join_squash", "Prims.squash", "FStar.Squash.get_proof" ]
[]
false
false
false
false
false
let get_squashed #b a =
let p = get_proof a in join_squash #b p
false
FStar.Classical.fst
FStar.Classical.impl_intro_gtot
val impl_intro_gtot (#p #q: Type0) ($_: (p -> GTot q)) : GTot (p ==> q)
val impl_intro_gtot (#p #q: Type0) ($_: (p -> GTot q)) : GTot (p ==> q)
let impl_intro_gtot #p #q f = return_squash f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 45, "start_col": 0, "start_line": 45 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (_: p -> Prims.GTot q) -> Prims.GTot (p ==> q)
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Squash.return_squash", "Prims.l_imp" ]
[]
false
false
false
false
false
let impl_intro_gtot #p #q f =
return_squash f
false
FStar.Classical.fst
FStar.Classical.give_witness_from_squash
val give_witness_from_squash (#a: Type) (_: squash a) : Lemma (ensures a)
val give_witness_from_squash (#a: Type) (_: squash a) : Lemma (ensures a)
let give_witness_from_squash #a x = x
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 23, "start_col": 0, "start_line": 23 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.squash a -> FStar.Pervasives.Lemma (ensures a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims.unit" ]
[]
true
false
true
false
false
let give_witness_from_squash #a x =
x
false
FStar.Classical.fst
FStar.Classical.give_witness
val give_witness (#a: Type) (_: a) : Lemma (ensures a)
val give_witness (#a: Type) (_: a) : Lemma (ensures a)
let give_witness #a x = return_squash x
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 21, "start_col": 0, "start_line": 21 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Classical open FStar.Squash
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> FStar.Pervasives.Lemma (ensures a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Squash.return_squash", "Prims.unit" ]
[]
true
false
true
false
false
let give_witness #a x =
return_squash x
false
FStar.Classical.fst
FStar.Classical.get_equality
val get_equality (#t: Type) (a b: t) : Pure (a == b) (requires (a == b)) (ensures (fun _ -> True))
val get_equality (#t: Type) (a b: t) : Pure (a == b) (requires (a == b)) (ensures (fun _ -> True))
let get_equality #t a b = get_squashed #(equals a b) (a == b)
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 38, "start_col": 0, "start_line": 38 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: t -> b: t -> Prims.Pure (a == b)
Prims.Pure
[]
[]
[ "FStar.Classical.get_squashed", "Prims.equals", "Prims.eq2" ]
[]
false
false
false
false
false
let get_equality #t a b =
get_squashed #(equals a b) (a == b)
false
FStar.Classical.fst
FStar.Classical.move_requires_2
val move_requires_2 (#a #b: Type) (#p #q: (a -> b -> Type)) ($_: (x: a -> y: b -> Lemma (requires (p x y)) (ensures (q x y)))) (x: a) (y: b) : Lemma (p x y ==> q x y)
val move_requires_2 (#a #b: Type) (#p #q: (a -> b -> Type)) ($_: (x: a -> y: b -> Lemma (requires (p x y)) (ensures (q x y)))) (x: a) (y: b) : Lemma (p x y ==> q x y)
let move_requires_2 #a #b #p #q f x y = move_requires (f x) y
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 64, "start_col": 0, "start_line": 64 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> y: b -> FStar.Pervasives.Lemma (requires p x y) (ensures q x y)) -> x: a -> y: b -> FStar.Pervasives.Lemma (ensures p x y ==> q x y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.move_requires" ]
[]
true
false
true
false
false
let move_requires_2 #a #b #p #q f x y =
move_requires (f x) y
false
Spec.Poly1305.fst
Spec.Poly1305.encode
val encode (len: size_nat{len <= size_block}) (b: lbytes len) : Tot felem
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 = Math.Lemmas.pow2_le_compat 128 (8 * len); assert_norm (pow2 128 + pow2 128 < prime); fadd (pow2 (8 * len)) (nat_from_bytes_le b)
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 54, "start_col": 0, "start_line": 51 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
len: Lib.IntTypes.size_nat{len <= Spec.Poly1305.size_block} -> b: Lib.ByteSequence.lbytes len -> Spec.Poly1305.felem
Prims.Tot
[ "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" ]
[]
false
false
false
false
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)
false
FStar.Classical.fst
FStar.Classical.move_requires_3
val move_requires_3 (#a #b #c: Type) (#p #q: (a -> b -> c -> Type)) ($_: (x: a -> y: b -> z: c -> Lemma (requires (p x y z)) (ensures (q x y z)))) (x: a) (y: b) (z: c) : Lemma (p x y z ==> q x y z)
val move_requires_3 (#a #b #c: Type) (#p #q: (a -> b -> c -> Type)) ($_: (x: a -> y: b -> z: c -> Lemma (requires (p x y z)) (ensures (q x y z)))) (x: a) (y: b) (z: c) : Lemma (p x y z ==> q x y z)
let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 66, "start_col": 0, "start_line": 66 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> y: b -> z: c -> FStar.Pervasives.Lemma (requires p x y z) (ensures q x y z)) -> x: a -> y: b -> z: c -> FStar.Pervasives.Lemma (ensures p x y z ==> q x y z)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.move_requires" ]
[]
true
false
true
false
false
let move_requires_3 #a #b #c #p #q f x y z =
move_requires (f x y) z
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_update_last
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
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
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 65, "start_col": 0, "start_line": 64 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
r: Spec.Poly1305.felem -> l: Lib.IntTypes.size_nat{l < 16} -> b: Lib.ByteSequence.lbytes l -> acc: Spec.Poly1305.felem -> Spec.Poly1305.felem
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
FStar.Classical.fst
FStar.Classical.forall_intro_squash_gtot
val forall_intro_squash_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (squash (p x)))) : Tot (squash (forall (x: a). p x))
val forall_intro_squash_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (squash (p x)))) : Tot (squash (forall (x: a). p x))
let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 94, "start_col": 0, "start_line": 90 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> Prims.GTot (Prims.squash (p x))) -> Prims.squash (forall (x: a). p x)
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "FStar.Squash.bind_squash", "Prims.l_Forall", "FStar.Squash.squash_double_arrow", "FStar.Squash.return_squash", "FStar.Classical.lemma_forall_intro_gtot" ]
[]
false
false
true
false
false
let forall_intro_squash_gtot #a #p f =
bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)
false
Spec.Poly1305.fst
Spec.Poly1305.poly1305_update
val poly1305_update (text: bytes) (acc r: felem) : Tot felem
val poly1305_update (text: bytes) (acc r: felem) : Tot felem
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
{ "file_name": "specs/Spec.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 72, "start_col": 0, "start_line": 68 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
text: Lib.ByteSequence.bytes -> acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> Spec.Poly1305.felem
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let poly1305_update (text: bytes) (acc r: felem) : Tot felem =
repeat_blocks #uint8 #felem size_block text (poly1305_update1 r size_block) (poly1305_update_last r) acc
false
FStar.Classical.fst
FStar.Classical.impl_intro
val impl_intro (#p #q: Type0) ($_: (p -> Lemma q)) : Lemma (p ==> q)
val impl_intro (#p #q: Type0) ($_: (p -> Lemma q)) : Lemma (p ==> q)
let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f)))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 88, "end_line": 50, "start_col": 0, "start_line": 49 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (_: p -> FStar.Pervasives.Lemma (ensures q)) -> FStar.Pervasives.Lemma (ensures p ==> q)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.give_witness", "Prims.l_imp", "FStar.Squash.squash_double_arrow", "FStar.Squash.return_squash", "FStar.Classical.lemma_to_squash_gtot" ]
[]
false
false
true
false
false
let impl_intro #p #q f =
give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f)))
false
FStar.Classical.fst
FStar.Classical.forall_intro_squash_gtot_join
val forall_intro_squash_gtot_join (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (squash (p x)))) : Tot (forall (x: a). p x)
val forall_intro_squash_gtot_join (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (squash (p x)))) : Tot (forall (x: a). p x)
let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 100, "start_col": 0, "start_line": 96 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> Prims.GTot (Prims.squash (p x))) -> (forall (x: a). p x)
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "FStar.Squash.join_squash", "FStar.Squash.bind_squash", "Prims.l_Forall", "FStar.Squash.squash_double_arrow", "FStar.Squash.return_squash", "FStar.Classical.lemma_forall_intro_gtot" ]
[]
false
false
false
false
false
let forall_intro_squash_gtot_join #a #p f =
join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f))
false
FStar.Classical.fst
FStar.Classical.forall_intro_with_pat
val forall_intro_with_pat (#a: Type) (#c: (x: a -> Type)) (#p: (x: a -> GTot Type0)) ($pat: (x: a -> Tot (c x))) ($_: (x: a -> Lemma (p x))) : Lemma (forall (x: a). {:pattern (pat x)} p x)
val forall_intro_with_pat (#a: Type) (#c: (x: a -> Type)) (#p: (x: a -> GTot Type0)) ($pat: (x: a -> Tot (c x))) ($_: (x: a -> Lemma (p x))) : Lemma (forall (x: a). {:pattern (pat x)} p x)
let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 63, "end_line": 104, "start_col": 0, "start_line": 104 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$pat: (x: a -> c x) -> $f: (x: a -> FStar.Pervasives.Lemma (ensures p x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). {:pattern pat x} p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro" ]
[]
true
false
true
false
false
let forall_intro_with_pat #a #c #p pat f =
forall_intro #a #p f
false
FStar.Classical.fst
FStar.Classical.forall_intro_sub
val forall_intro_sub (#a: Type) (#p: (a -> GTot Type)) (_: (x: a -> Lemma (p x))) : Lemma (forall (x: a). p x)
val forall_intro_sub (#a: Type) (#p: (a -> GTot Type)) (_: (x: a -> Lemma (p x))) : Lemma (forall (x: a). p x)
let forall_intro_sub #a #p f = forall_intro f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 106, "start_col": 0, "start_line": 106 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (x: a -> FStar.Pervasives.Lemma (ensures p x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro" ]
[]
true
false
true
false
false
let forall_intro_sub #a #p f =
forall_intro f
false
ExtractRefs.fst
ExtractRefs.copy_ref
val copy_ref (r: ref U32.t) : Steel (ref U32.t) (vptr r) (fun r' -> (vptr r) `star` (vptr r')) (requires fun _ -> True) (ensures fun h0 r' h1 -> sel r h0 == sel r h1 /\ sel r' h1 == sel r h1)
val copy_ref (r: ref U32.t) : Steel (ref U32.t) (vptr r) (fun r' -> (vptr r) `star` (vptr r')) (requires fun _ -> True) (ensures fun h0 r' h1 -> sel r h0 == sel r h1 /\ sel r' h1 == sel r h1)
let copy_ref (r:ref U32.t) : Steel (ref U32.t) (vptr r) // We allocated a new reference r', which is the return value (fun r' -> vptr r `star` vptr r') (requires fun _ -> True) (ensures fun h0 r' h1 -> // reference r was not modified sel r h0 == sel r h1 /\ // After copying, reference r' contains the same value as reference r sel r' h1 == sel r h1) = let x = read r in let r' = malloc x in r'
{ "file_name": "share/steel/tutorial/ExtractRefs.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 6, "end_line": 60, "start_col": 0, "start_line": 47 }
module ExtractRefs open FStar.Ghost open Steel.FractionalPermission open Steel.Effect.Atomic open Steel.Effect open Steel.Reference module U32 = FStar.UInt32 /// Some examples using Steel references with fractional permissions #push-options "--fuel 0 --ifuel 0 --ide_id_info_off" (** Swap examples **) /// A selector version of swap, more idiomatic in Steel let swap (r1 r2:ref U32.t) : Steel unit (vptr r1 `star` vptr r2) (fun _ -> vptr r1 `star` vptr r2) (requires fun _ -> True) (ensures fun h0 _ h1 -> sel r1 h0 == sel r2 h1 /\ sel r2 h0 == sel r1 h1) = let x1 = read r1 in let x2 = read r2 in write r2 x1; write r1 x2 (** Allocating and Freeing references *) /// Demonstrating standard reference operations let main_ref () : Steel U32.t emp (fun _ -> emp) (requires fun _ -> True) (ensures fun _ x _ -> x == 2ul) = // Allocating reference r let r = malloc 0ul in // Writing value 2 in the newly allocated reference write r 2ul; // Reading value of r in memory. This was set to 2 just above let v = read r in // Freeing reference r free r; // The returned value is equal to 1, the context is now empty v
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ExtractRefs.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.Reference.ref FStar.UInt32.t -> Steel.Effect.Steel (Steel.Reference.ref FStar.UInt32.t)
Steel.Effect.Steel
[]
[]
[ "Steel.Reference.ref", "FStar.UInt32.t", "Steel.Reference.malloc", "Steel.Reference.read", "Steel.Reference.vptr", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Steel.Reference.sel" ]
[]
false
true
false
false
false
let copy_ref (r: ref U32.t) : Steel (ref U32.t) (vptr r) (fun r' -> (vptr r) `star` (vptr r')) (requires fun _ -> True) (ensures fun h0 r' h1 -> sel r h0 == sel r h1 /\ sel r' h1 == sel r h1) =
let x = read r in let r' = malloc x in r'
false
FStar.Classical.fst
FStar.Classical.get_forall
val get_forall (#a: Type) (p: (a -> GTot Type0)) : Pure (forall (x: a). p x) (requires (forall (x: a). p x)) (ensures (fun _ -> True))
val get_forall (#a: Type) (p: (a -> GTot Type0)) : Pure (forall (x: a). p x) (requires (forall (x: a). p x)) (ensures (fun _ -> True))
let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x)
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 78, "start_col": 0, "start_line": 74 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: (_: a -> Prims.GTot Type0) -> Prims.Pure (forall (x: a). p x)
Prims.Pure
[]
[]
[ "FStar.Classical.get_squashed", "Prims.l_Forall", "Prims.unit", "FStar.Pervasives.norm_spec", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Prims.logical", "Prims._assert", "Prims.eq2", "FStar.Pervasives.norm", "Prims.squash" ]
[]
false
false
false
false
false
let get_forall #a p =
let t = (forall (x: a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x: a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x)
false
FStar.Classical.fst
FStar.Classical.forall_intro_2
val forall_intro_2 (#a: Type) (#b: (a -> Type)) (#p: (x: a -> b x -> GTot Type0)) ($_: (x: a -> y: b x -> Lemma (p x y))) : Lemma (forall (x: a) (y: b x). p x y)
val forall_intro_2 (#a: Type) (#b: (a -> Type)) (#p: (x: a -> b x -> GTot Type0)) ($_: (x: a -> y: b x -> Lemma (p x y))) : Lemma (forall (x: a) (y: b x). p x y)
let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 111, "start_col": 0, "start_line": 109 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> y: b x -> FStar.Pervasives.Lemma (ensures p x y)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b x). p x y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_Forall" ]
[]
false
false
true
false
false
let forall_intro_2 #a #b #p f =
let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g
false
FStar.Classical.fst
FStar.Classical.forall_intro_2_with_pat
val forall_intro_2_with_pat (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#p: (x: a -> b x -> GTot Type0)) ($pat: (x: a -> y: b x -> Tot (c x y))) ($_: (x: a -> y: b x -> Lemma (p x y))) : Lemma (forall (x: a) (y: b x). {:pattern (pat x y)} p x y)
val forall_intro_2_with_pat (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#p: (x: a -> b x -> GTot Type0)) ($pat: (x: a -> y: b x -> Tot (c x y))) ($_: (x: a -> y: b x -> Lemma (p x y))) : Lemma (forall (x: a) (y: b x). {:pattern (pat x y)} p x y)
let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 113, "start_col": 0, "start_line": 113 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$pat: (x: a -> y: b x -> c x y) -> $f: (x: a -> y: b x -> FStar.Pervasives.Lemma (ensures p x y)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b x). {:pattern pat x y} p x y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_2" ]
[]
true
false
true
false
false
let forall_intro_2_with_pat #a #b #c #p pat f =
forall_intro_2 #a #b #p f
false
FStar.Classical.fst
FStar.Classical.gtot_to_lemma
val gtot_to_lemma (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (p x))) (x: a) : Lemma (p x)
val gtot_to_lemma (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (p x))) (x: a) : Lemma (p x)
let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 69, "end_line": 88, "start_col": 0, "start_line": 88 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> Prims.GTot (p x)) -> x: a -> FStar.Pervasives.Lemma (ensures p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Squash.give_proof", "FStar.Squash.return_squash", "Prims.unit" ]
[]
true
false
true
false
false
let gtot_to_lemma #a #p f x =
give_proof #(p x) (return_squash (f x))
false
FStar.Classical.fst
FStar.Classical.forall_intro_gtot
val forall_intro_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (p x))) : Tot (squash (forall (x: a). p x))
val forall_intro_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (p x))) : Tot (squash (forall (x: a). p x))
let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) ()
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 84, "start_col": 0, "start_line": 81 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> Prims.GTot (p x)) -> Prims.squash (forall (x: a). p x)
Prims.Tot
[ "total" ]
[]
[ "FStar.Squash.return_squash", "Prims.l_Forall", "Prims.squash" ]
[]
false
false
true
false
false
let forall_intro_gtot #a #p f =
let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) ()
false
FStar.Classical.fst
FStar.Classical.forall_intro_3
val forall_intro_3 (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#p: (x: a -> y: b x -> z: c x y -> Type0)) ($_: (x: a -> y: b x -> z: c x y -> Lemma (p x y z))) : Lemma (forall (x: a) (y: b x) (z: c x y). p x y z)
val forall_intro_3 (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#p: (x: a -> y: b x -> z: c x y -> Type0)) ($_: (x: a -> y: b x -> z: c x y -> Lemma (p x y z))) : Lemma (forall (x: a) (y: b x) (z: c x y). p x y z)
let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 117, "start_col": 0, "start_line": 115 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> y: b x -> z: c x y -> FStar.Pervasives.Lemma (ensures p x y z)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b x) (z: c x y). p x y z)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_Forall", "FStar.Classical.forall_intro_2" ]
[]
false
false
true
false
false
let forall_intro_3 #a #b #c #p f =
let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g
false
FStar.Classical.fst
FStar.Classical.forall_intro_3_with_pat
val forall_intro_3_with_pat (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#d: (x: a -> y: b x -> z: c x y -> Type)) (#p: (x: a -> y: b x -> z: c x y -> GTot Type0)) ($pat: (x: a -> y: b x -> z: c x y -> Tot (d x y z))) ($_: (x: a -> y: b x -> z: c x y -> Lemma (p x y z))) : Lemma (forall (x: a) (y: b x) (z: c x y). {:pattern (pat x y z)} p x y z)
val forall_intro_3_with_pat (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#d: (x: a -> y: b x -> z: c x y -> Type)) (#p: (x: a -> y: b x -> z: c x y -> GTot Type0)) ($pat: (x: a -> y: b x -> z: c x y -> Tot (d x y z))) ($_: (x: a -> y: b x -> z: c x y -> Lemma (p x y z))) : Lemma (forall (x: a) (y: b x) (z: c x y). {:pattern (pat x y z)} p x y z)
let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 79, "end_line": 119, "start_col": 0, "start_line": 119 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$pat: (x: a -> y: b x -> z: c x y -> d x y z) -> $f: (x: a -> y: b x -> z: c x y -> FStar.Pervasives.Lemma (ensures p x y z)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b x) (z: c x y). {:pattern pat x y z} p x y z)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_3" ]
[]
true
false
true
false
false
let forall_intro_3_with_pat #a #b #c #d #p pat f =
forall_intro_3 #a #b #c #p f
false
FStar.Classical.fst
FStar.Classical.forall_intro_4
val forall_intro_4 (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#d: (x: a -> y: b x -> z: c x y -> Type)) (#p: (x: a -> y: b x -> z: c x y -> w: d x y z -> Type0)) ($_: (x: a -> y: b x -> z: c x y -> w: d x y z -> Lemma (p x y z w))) : Lemma (forall (x: a) (y: b x) (z: c x y) (w: d x y z). p x y z w)
val forall_intro_4 (#a: Type) (#b: (a -> Type)) (#c: (x: a -> y: b x -> Type)) (#d: (x: a -> y: b x -> z: c x y -> Type)) (#p: (x: a -> y: b x -> z: c x y -> w: d x y z -> Type0)) ($_: (x: a -> y: b x -> z: c x y -> w: d x y z -> Lemma (p x y z w))) : Lemma (forall (x: a) (y: b x) (z: c x y) (w: d x y z). p x y z w)
let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 125, "start_col": 0, "start_line": 121 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> y: b x -> z: c x y -> w: d x y z -> FStar.Pervasives.Lemma (ensures p x y z w)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b x) (z: c x y) (w: d x y z). p x y z w)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_Forall", "FStar.Classical.forall_intro_3" ]
[]
false
false
true
false
false
let forall_intro_4 #a #b #c #d #p f =
let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g
false
FStar.Classical.fst
FStar.Classical.impl_intro_gen
val impl_intro_gen (#p: Type0) (#q: (squash p -> Tot Type0)) (_: (squash p -> Lemma (q ()))) : Lemma (p ==> q ())
val impl_intro_gen (#p: Type0) (#q: (squash p -> Tot Type0)) (_: (squash p -> Lemma (q ()))) : Lemma (p ==> q ())
let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g ()
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 71, "start_col": 0, "start_line": 69 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.squash p -> FStar.Pervasives.Lemma (ensures q ())) -> FStar.Pervasives.Lemma (ensures p ==> q ())
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.move_requires", "Prims.l_imp", "FStar.Squash.give_proof", "FStar.Squash.get_proof" ]
[]
false
false
true
false
false
let impl_intro_gen #p #q f =
let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g ()
false
FStar.Classical.fst
FStar.Classical.lemma_forall_intro_gtot
val lemma_forall_intro_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (p x))) : Lemma (forall (x: a). p x)
val lemma_forall_intro_gtot (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> GTot (p x))) : Lemma (forall (x: a). p x)
let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f)
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 86, "start_col": 0, "start_line": 86 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> Prims.GTot (p x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Classical.give_witness", "Prims.squash", "Prims.l_Forall", "FStar.Classical.forall_intro_gtot", "Prims.unit" ]
[]
false
false
true
false
false
let lemma_forall_intro_gtot #a #p f =
give_witness (forall_intro_gtot #a #p f)
false
FStar.Classical.fst
FStar.Classical.move_requires
val move_requires (#a: Type) (#p #q: (a -> Type)) ($_: (x: a -> Lemma (requires (p x)) (ensures (q x)))) (x: a) : Lemma (p x ==> q x)
val move_requires (#a: Type) (#p #q: (a -> Type)) ($_: (x: a -> Lemma (requires (p x)) (ensures (q x)))) (x: a) : Lemma (p x ==> q x)
let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp)))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 62, "start_col": 0, "start_line": 52 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> FStar.Pervasives.Lemma (requires p x) (ensures q x)) -> x: a -> FStar.Pervasives.Lemma (ensures p x ==> q x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Squash.give_proof", "Prims.l_imp", "FStar.Squash.bind_squash", "Prims.l_or", "Prims.l_not", "FStar.Squash.get_proof", "Prims.sum", "FStar.Classical.give_witness" ]
[]
false
false
true
false
false
let move_requires #a #p #q f x =
give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp)))
false
FStar.Classical.fst
FStar.Classical.forall_intro
val forall_intro (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> Lemma (p x))) : Lemma (forall (x: a). p x)
val forall_intro (#a: Type) (#p: (a -> GTot Type)) ($_: (x: a -> Lemma (p x))) : Lemma (forall (x: a). p x)
let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f))
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 97, "end_line": 102, "start_col": 0, "start_line": 102 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> FStar.Pervasives.Lemma (ensures p x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.give_witness", "Prims.l_Forall", "FStar.Classical.forall_intro_squash_gtot", "FStar.Classical.lemma_to_squash_gtot" ]
[]
false
false
true
false
false
let forall_intro #a #p f =
give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f))
false
FStar.Classical.fst
FStar.Classical.forall_impl_intro
val forall_impl_intro (#a: Type) (#p #q: (a -> GTot Type)) ($_: (x: a -> squash (p x) -> Lemma (q x))) : Lemma (forall x. p x ==> q x)
val forall_impl_intro (#a: Type) (#p #q: (a -> GTot Type)) ($_: (x: a -> squash (p x) -> Lemma (q x))) : Lemma (forall x. p x ==> q x)
let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f')
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 130, "start_col": 0, "start_line": 128 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> _: Prims.squash (p x) -> FStar.Pervasives.Lemma (ensures q x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). p x ==> q x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_imp", "FStar.Classical.move_requires", "FStar.Squash.get_proof" ]
[]
false
false
true
false
false
let forall_impl_intro #a #p #q f =
let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f')
false
FStar.Classical.fst
FStar.Classical.ghost_lemma
val ghost_lemma (#a: Type) (#p: (a -> GTot Type0)) (#q: (a -> unit -> GTot Type0)) ($_: (x: a -> Lemma (requires p x) (ensures (q x ())))) : Lemma (forall (x: a). p x ==> q x ())
val ghost_lemma (#a: Type) (#p: (a -> GTot Type0)) (#q: (a -> unit -> GTot Type0)) ($_: (x: a -> Lemma (requires p x) (ensures (q x ())))) : Lemma (forall (x: a). p x ==> q x ())
let ghost_lemma #a #p #q f = let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> (* basically, the same as above *) give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 148, "start_col": 0, "start_line": 133 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f')
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> FStar.Pervasives.Lemma (requires p x) (ensures q x ())) -> FStar.Pervasives.Lemma (ensures forall (x: a). p x ==> q x ())
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_True", "FStar.Squash.give_proof", "FStar.Squash.bind_squash", "Prims.l_or", "Prims.l_not", "FStar.Squash.get_proof", "Prims.sum", "FStar.Classical.give_witness" ]
[]
false
false
true
false
false
let ghost_lemma #a #p #q f =
let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem
false
FStar.Classical.fst
FStar.Classical.or_elim
val or_elim (#l #r: Type0) (#goal: (squash (l \/ r) -> Tot Type0)) (hl: (squash l -> Lemma (goal ()))) (hr: (squash r -> Lemma (goal ()))) : Lemma ((l \/ r) ==> goal ())
val or_elim (#l #r: Type0) (#goal: (squash (l \/ r) -> Tot Type0)) (hl: (squash l -> Lemma (goal ()))) (hr: (squash r -> Lemma (goal ()))) : Lemma ((l \/ r) ==> goal ())
let or_elim #l #r #goal hl hr = impl_intro_gen #l #(fun _ -> goal ()) hl; impl_intro_gen #r #(fun _ -> goal ()) hr
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 186, "start_col": 0, "start_line": 184 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f') let ghost_lemma #a #p #q f = let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> (* basically, the same as above *) give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem (*** Existential quantification *) let exists_intro #a p witness = () #push-options "--warn_error -271" //local SMT pattern misses variables let exists_intro_not_all_not (#a:Type) (#p:a -> Type) ($f: (x:a -> Lemma (~(p x))) -> Lemma False) : Lemma (exists x. p x) = let open FStar.Squash in let aux () : Lemma (requires (forall x. ~(p x))) (ensures False) [SMTPat ()] = bind_squash (get_proof (forall x. ~ (p x))) (fun (g: (forall x. ~ (p x))) -> bind_squash #(x:a -> GTot (~(p x))) #Prims.empty g (fun (h:(x:a -> GTot (~(p x)))) -> f h)) in () #pop-options let forall_to_exists #a #p #r f = forall_intro f let forall_to_exists_2 #a #p #b #q #r f = forall_intro_2 f let exists_elim goal #a #p have f = bind_squash #_ #goal (join_squash have) (fun (| x , pf |) -> return_squash pf; f x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
hl: (_: Prims.squash l -> FStar.Pervasives.Lemma (ensures goal ())) -> hr: (_: Prims.squash r -> FStar.Pervasives.Lemma (ensures goal ())) -> FStar.Pervasives.Lemma (ensures l \/ r ==> goal ())
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims.l_or", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.impl_intro_gen" ]
[]
false
false
true
false
false
let or_elim #l #r #goal hl hr =
impl_intro_gen #l #(fun _ -> goal ()) hl; impl_intro_gen #r #(fun _ -> goal ()) hr
false
FStar.Classical.fst
FStar.Classical.forall_to_exists_2
val forall_to_exists_2 (#a: Type) (#p: (a -> Type)) (#b: Type) (#q: (b -> Type)) (#r: Type) ($f: (x: a -> y: b -> Lemma ((p x /\ q y) ==> r))) : Lemma (((exists (x: a). p x) /\ (exists (y: b). q y)) ==> r)
val forall_to_exists_2 (#a: Type) (#p: (a -> Type)) (#b: Type) (#q: (b -> Type)) (#r: Type) ($f: (x: a -> y: b -> Lemma ((p x /\ q y) ==> r))) : Lemma (((exists (x: a). p x) /\ (exists (y: b). q y)) ==> r)
let forall_to_exists_2 #a #p #b #q #r f = forall_intro_2 f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 173, "start_col": 0, "start_line": 173 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f') let ghost_lemma #a #p #q f = let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> (* basically, the same as above *) give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem (*** Existential quantification *) let exists_intro #a p witness = () #push-options "--warn_error -271" //local SMT pattern misses variables let exists_intro_not_all_not (#a:Type) (#p:a -> Type) ($f: (x:a -> Lemma (~(p x))) -> Lemma False) : Lemma (exists x. p x) = let open FStar.Squash in let aux () : Lemma (requires (forall x. ~(p x))) (ensures False) [SMTPat ()] = bind_squash (get_proof (forall x. ~ (p x))) (fun (g: (forall x. ~ (p x))) -> bind_squash #(x:a -> GTot (~(p x))) #Prims.empty g (fun (h:(x:a -> GTot (~(p x)))) -> f h)) in () #pop-options let forall_to_exists #a #p #r f = forall_intro f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> y: b -> FStar.Pervasives.Lemma (ensures p x /\ q y ==> r)) -> FStar.Pervasives.Lemma (ensures (exists (x: a). p x) /\ (exists (y: b). q y) ==> r)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.l_and", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_2" ]
[]
false
false
true
false
false
let forall_to_exists_2 #a #p #b #q #r f =
forall_intro_2 f
false
FStar.Classical.fst
FStar.Classical.exists_intro_not_all_not
val exists_intro_not_all_not (#a: Type) (#p: (a -> Type)) ($f: ((x: a -> Lemma (~(p x))) -> Lemma False)) : Lemma (exists x. p x)
val exists_intro_not_all_not (#a: Type) (#p: (a -> Type)) ($f: ((x: a -> Lemma (~(p x))) -> Lemma False)) : Lemma (exists x. p x)
let exists_intro_not_all_not (#a:Type) (#p:a -> Type) ($f: (x:a -> Lemma (~(p x))) -> Lemma False) : Lemma (exists x. p x) = let open FStar.Squash in let aux () : Lemma (requires (forall x. ~(p x))) (ensures False) [SMTPat ()] = bind_squash (get_proof (forall x. ~ (p x))) (fun (g: (forall x. ~ (p x))) -> bind_squash #(x:a -> GTot (~(p x))) #Prims.empty g (fun (h:(x:a -> GTot (~(p x)))) -> f h)) in ()
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 168, "start_col": 0, "start_line": 154 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f') let ghost_lemma #a #p #q f = let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> (* basically, the same as above *) give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem (*** Existential quantification *) let exists_intro #a p witness = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (_: (x: a -> FStar.Pervasives.Lemma (ensures ~(p x))) -> FStar.Pervasives.Lemma (ensures Prims.l_False)) -> FStar.Pervasives.Lemma (ensures exists (x: a). p x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_not", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.l_False", "Prims.l_Forall", "Prims.Cons", "FStar.Pervasives.smt_pat", "FStar.Squash.bind_squash", "Prims.empty", "FStar.Squash.get_proof", "Prims.l_Exists" ]
[]
false
false
true
false
false
let exists_intro_not_all_not (#a: Type) (#p: (a -> Type)) ($f: ((x: a -> Lemma (~(p x))) -> Lemma False)) : Lemma (exists x. p x) =
let open FStar.Squash in let aux () : Lemma (requires (forall x. ~(p x))) (ensures False) [SMTPat ()] = bind_squash (get_proof (forall x. ~(p x))) (fun (g: (forall x. ~(p x))) -> bind_squash #(x: a -> GTot (~(p x))) #Prims.empty g (fun (h: (x: a -> GTot (~(p x)))) -> f h)) in ()
false
FStar.Classical.fst
FStar.Classical.exists_elim
val exists_elim (goal #a: Type) (#p: (a -> Type)) (_: squash (exists (x: a). p x)) (_: (x: a{p x} -> GTot (squash goal))) : Lemma goal
val exists_elim (goal #a: Type) (#p: (a -> Type)) (_: squash (exists (x: a). p x)) (_: (x: a{p x} -> GTot (squash goal))) : Lemma goal
let exists_elim goal #a #p have f = bind_squash #_ #goal (join_squash have) (fun (| x , pf |) -> return_squash pf; f x)
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 181, "start_col": 0, "start_line": 175 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f') let ghost_lemma #a #p #q f = let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> (* basically, the same as above *) give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem (*** Existential quantification *) let exists_intro #a p witness = () #push-options "--warn_error -271" //local SMT pattern misses variables let exists_intro_not_all_not (#a:Type) (#p:a -> Type) ($f: (x:a -> Lemma (~(p x))) -> Lemma False) : Lemma (exists x. p x) = let open FStar.Squash in let aux () : Lemma (requires (forall x. ~(p x))) (ensures False) [SMTPat ()] = bind_squash (get_proof (forall x. ~ (p x))) (fun (g: (forall x. ~ (p x))) -> bind_squash #(x:a -> GTot (~(p x))) #Prims.empty g (fun (h:(x:a -> GTot (~(p x)))) -> f h)) in () #pop-options let forall_to_exists #a #p #r f = forall_intro f let forall_to_exists_2 #a #p #b #q #r f = forall_intro_2 f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
goal: Type0 -> have: Prims.squash (exists (x: a). p x) -> f: (x: a{p x} -> Prims.GTot (Prims.squash goal)) -> FStar.Pervasives.Lemma (ensures goal)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims.l_Exists", "FStar.Squash.bind_squash", "Prims.dtuple2", "FStar.Squash.join_squash", "Prims.unit", "FStar.Squash.return_squash" ]
[]
false
false
true
false
false
let exists_elim goal #a #p have f =
bind_squash #_ #goal (join_squash have) (fun (| x , pf |) -> return_squash pf; f x)
false
FStar.Classical.fst
FStar.Classical.forall_to_exists
val forall_to_exists (#a: Type) (#p: (a -> Type)) (#r: Type) ($_: (x: a -> Lemma (p x ==> r))) : Lemma ((exists (x: a). p x) ==> r)
val forall_to_exists (#a: Type) (#p: (a -> Type)) (#r: Type) ($_: (x: a -> Lemma (p x ==> r))) : Lemma ((exists (x: a). p x) ==> r)
let forall_to_exists #a #p #r f = forall_intro f
{ "file_name": "ulib/FStar.Classical.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 171, "start_col": 0, "start_line": 171 }
(* 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.Classical open FStar.Squash let give_witness #a x = return_squash x let give_witness_from_squash #a x = x let lemma_to_squash_gtot #a #p f x = f x; get_proof (p x) val get_squashed (#b a: Type) : Pure a (requires (a /\ a == squash b)) (ensures (fun _ -> True)) #push-options "--smtencoding.valid_intro true --smtencoding.valid_elim true" [@@ noextract_to "FSharp"] let get_squashed #b a = let p = get_proof a in join_squash #b p #pop-options let get_equality #t a b = get_squashed #(equals a b) (a == b) let impl_to_arrow #a #b impl sx = bind_squash #(a -> GTot b) impl (fun f -> bind_squash sx (fun x -> return_squash (f x))) let arrow_to_impl #a #b f = squash_double_arrow (return_squash (fun x -> f (return_squash x))) let impl_intro_gtot #p #q f = return_squash f let impl_intro_tot #p #q f = return_squash #(p -> GTot q) f let impl_intro #p #q f = give_witness #(p ==> q) (squash_double_arrow (return_squash (lemma_to_squash_gtot f))) let move_requires #a #p #q f x = give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x) | Prims.Right hnp -> give_witness hnp))) let move_requires_2 #a #b #p #q f x y = move_requires (f x) y let move_requires_3 #a #b #c #p #q f x y z = move_requires (f x y) z // Thanks KM, CH and SZ let impl_intro_gen #p #q f = let g () : Lemma (requires p) (ensures (p ==> q ())) = give_proof #(q ()) (f (get_proof p)) in move_requires g () (*** Universal quantification *) let get_forall #a p = let t = (forall (x:a). p x) in assert (norm [delta; delta_only [`%l_Forall]] t == (squash (x:a -> GTot (p x)))); norm_spec [delta; delta_only [`%l_Forall]] t; get_squashed #(x: a -> GTot (p x)) (forall (x: a). p x) (* TODO: Maybe this should move to FStar.Squash.fst *) let forall_intro_gtot #a #p f = let id (#a: Type) (x: a) = x in let h:(x: a -> GTot (id (p x))) = fun x -> f x in return_squash #(forall (x: a). id (p x)) () let lemma_forall_intro_gtot #a #p f = give_witness (forall_intro_gtot #a #p f) let gtot_to_lemma #a #p f x = give_proof #(p x) (return_squash (f x)) let forall_intro_squash_gtot #a #p f = bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f) let forall_intro_squash_gtot_join #a #p f = join_squash (bind_squash #(x: a -> GTot (p x)) #(forall (x: a). p x) (squash_double_arrow #a #p (return_squash f)) (fun f -> lemma_forall_intro_gtot #a #p f)) let forall_intro #a #p f = give_witness (forall_intro_squash_gtot (lemma_to_squash_gtot #a #p f)) let forall_intro_with_pat #a #c #p pat f = forall_intro #a #p f let forall_intro_sub #a #p f = forall_intro f (* Some basic stuff, should be moved to FStar.Squash, probably *) let forall_intro_2 #a #b #p f = let g: x: a -> Lemma (forall (y: b x). p x y) = fun x -> forall_intro (f x) in forall_intro g let forall_intro_2_with_pat #a #b #c #p pat f = forall_intro_2 #a #b #p f let forall_intro_3 #a #b #c #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y). p x y z) = fun x -> forall_intro_2 (f x) in forall_intro g let forall_intro_3_with_pat #a #b #c #d #p pat f = forall_intro_3 #a #b #c #p f let forall_intro_4 #a #b #c #d #p f = let g: x: a -> Lemma (forall (y: b x) (z: c x y) (w: d x y z). p x y z w) = fun x -> forall_intro_3 (f x) in forall_intro g let forall_impl_intro #a #p #q f = let f' (x: a) : Lemma (requires (p x)) (ensures (q x)) = f x (get_proof (p x)) in forall_intro (move_requires f') let ghost_lemma #a #p #q f = let lem: x: a -> Lemma (p x ==> q x ()) = (fun x -> (* basically, the same as above *) give_proof (bind_squash (get_proof (l_or (p x) (~(p x)))) (fun (b: l_or (p x) (~(p x))) -> bind_squash b (fun (b': Prims.sum (p x) (~(p x))) -> match b' with | Prims.Left hp -> give_witness hp; f x; get_proof (p x ==> q x ()) | Prims.Right hnp -> give_witness hnp)))) in forall_intro lem (*** Existential quantification *) let exists_intro #a p witness = () #push-options "--warn_error -271" //local SMT pattern misses variables let exists_intro_not_all_not (#a:Type) (#p:a -> Type) ($f: (x:a -> Lemma (~(p x))) -> Lemma False) : Lemma (exists x. p x) = let open FStar.Squash in let aux () : Lemma (requires (forall x. ~(p x))) (ensures False) [SMTPat ()] = bind_squash (get_proof (forall x. ~ (p x))) (fun (g: (forall x. ~ (p x))) -> bind_squash #(x:a -> GTot (~(p x))) #Prims.empty g (fun (h:(x:a -> GTot (~(p x)))) -> f h)) in () #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Squash.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.Classical.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (x: a -> FStar.Pervasives.Lemma (ensures p x ==> r)) -> FStar.Pervasives.Lemma (ensures (exists (x: a). p x) ==> r)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro" ]
[]
false
false
true
false
false
let forall_to_exists #a #p #r f =
forall_intro f
false
LowParse.Low.IfThenElse.fst
LowParse.Low.IfThenElse.clens_ifthenelse_tag
val clens_ifthenelse_tag (#p: parse_ifthenelse_param) (s: serialize_ifthenelse_param p) : Tot (clens p.parse_ifthenelse_t p.parse_ifthenelse_tag_t)
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) = { clens_cond = (fun _ -> True); clens_get = (fun (x: p.parse_ifthenelse_t) -> dfst (s.serialize_ifthenelse_synth_recip x)); }
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 138, "start_col": 0, "start_line": 131 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: 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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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)) }
false
Pulse.Checker.AssertWithBinders.fst
Pulse.Checker.AssertWithBinders.check
val check (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_ProofHintWithBinders? st.term }) (check:check_t) : T.Tac (checker_result_t g pre post_hint)
val check (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_ProofHintWithBinders? st.term }) (check:check_t) : T.Tac (checker_result_t g pre post_hint)
let check (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (st:st_term { Tm_ProofHintWithBinders? st.term }) (check:check_t) : T.Tac (checker_result_t g pre post_hint) = let g = push_context g "check_assert" st.range in let Tm_ProofHintWithBinders { hint_type; binders=bs; t=body } = st.term in match hint_type with | WILD -> let st = check_wild g pre st in check g pre pre_typing post_hint res_ppname st | SHOW_PROOF_STATE r -> let open FStar.Stubs.Pprint in let open Pulse.PP in let msg = [ text "Current context:" ^^ indent (pp pre) ] in fail_doc_env true g (Some r) msg | RENAME { pairs; goal } -> let st = check_renaming g pre st in check g pre pre_typing post_hint res_ppname st | REWRITE { t1; t2 } -> ( match bs with | [] -> let t = { st with term = Tm_Rewrite { t1; t2 } } in check g pre pre_typing post_hint res_ppname { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } | _ -> let t = { st with term = Tm_Rewrite { t1; t2 } } in let body = { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } in let st = { st with term = Tm_ProofHintWithBinders { hint_type = ASSERT { p = t1 }; binders = bs; t = body } } in check g pre pre_typing post_hint res_ppname st ) | ASSERT { p = v } -> let bs = infer_binder_types g bs v in let (| uvs, v_opened, body_opened |) = open_binders g bs (mk_env (fstar_env g)) v body in let v, body = v_opened, body_opened in let (| v, d |) = PC.check_vprop (push_env g uvs) v in let (| g1, nts, _, pre', k_frame |) = Prover.prove pre_typing uvs d in // // No need to check effect labels for the uvs solution here, // since we are checking the substituted body anyway, // if some of them are ghost when they shouldn't be, // it will get caught // let (| x, x_ty, pre'', g2, k |) = check g1 (tm_star (PS.nt_subst_term v nts) pre') (RU.magic ()) post_hint res_ppname (PS.nt_subst_st_term body nts) in (| x, x_ty, pre'', g2, k_elab_trans k_frame k |) | UNFOLD { names; p=v } | FOLD { names; p=v } -> let (| uvs, v_opened, body_opened |) = let bs = infer_binder_types g bs v in open_binders g bs (mk_env (fstar_env g)) v body in check_unfoldable g v; let v_opened, t_rem = PC.instantiate_term_implicits (push_env g uvs) v_opened in let uvs, v_opened = let (| uvs_rem, v_opened |) = add_rem_uvs (push_env g uvs) t_rem (mk_env (fstar_env g)) v_opened in push_env uvs uvs_rem, v_opened in let lhs, rhs = match hint_type with | UNFOLD _ -> v_opened, unfold_defs (push_env g uvs) None v_opened | FOLD { names=ns } -> unfold_defs (push_env g uvs) ns v_opened, v_opened in let uvs_bs = uvs |> bindings_with_ppname |> L.rev in let uvs_closing = uvs_bs |> closing in let lhs = subst_term lhs uvs_closing in let rhs = subst_term rhs uvs_closing in let body = subst_st_term body_opened uvs_closing in let bs = close_binders uvs_bs in let rw = { term = Tm_Rewrite { t1 = lhs; t2 = rhs }; range = st.range; effect_tag = as_effect_hint STT_Ghost } in let st = { term = Tm_Bind { binder = as_binder (tm_fstar (`unit) st.range); head = rw; body }; range = st.range; effect_tag = body.effect_tag } in let st = match bs with | [] -> st | _ -> { term = Tm_ProofHintWithBinders { hint_type = ASSERT { p = lhs }; binders = bs; t = st }; range = st.range; effect_tag = st.effect_tag } in check g pre pre_typing post_hint res_ppname st
{ "file_name": "lib/steel/pulse/Pulse.Checker.AssertWithBinders.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 464, "start_col": 0, "start_line": 351 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.AssertWithBinders open Pulse.Syntax open Pulse.Typing open Pulse.Checker.Base open Pulse.Elaborate.Pure open Pulse.Typing.Env module L = FStar.List.Tot module T = FStar.Tactics.V2 module R = FStar.Reflection.V2 module PC = Pulse.Checker.Pure module P = Pulse.Syntax.Printer module N = Pulse.Syntax.Naming module PS = Pulse.Checker.Prover.Substs module Prover = Pulse.Checker.Prover module Env = Pulse.Typing.Env open Pulse.Show module RU = Pulse.RuntimeUtils let is_host_term (t:R.term) = not (R.Tv_Unknown? (R.inspect_ln t)) let debug_log = Pulse.Typing.debug_log "with_binders" let option_must (f:option 'a) (msg:string) : T.Tac 'a = match f with | Some x -> x | None -> T.fail msg let rec refl_abs_binders (t:R.term) (acc:list binder) : T.Tac (list binder) = let open R in match inspect_ln t with | Tv_Abs b body -> let {sort; ppname} = R.inspect_binder b in let sort = option_must (readback_ty sort) (Printf.sprintf "Failed to readback elaborated binder sort %s in refl_abs_binders" (T.term_to_string sort)) in refl_abs_binders body ((mk_binder_ppname sort (mk_ppname ppname (RU.range_of_term t)))::acc) | _ -> L.rev acc let infer_binder_types (g:env) (bs:list binder) (v:vprop) : T.Tac (list binder) = match bs with | [] -> [] | _ -> let g = push_context g "infer_binder_types" v.range in let tv = elab_term v in if not (is_host_term tv) then fail g (Some v.range) (Printf.sprintf "assert.infer_binder_types: elaborated %s to %s, which failed the host term check" (P.term_to_string v) (T.term_to_string tv)); let as_binder (b:binder) : R.binder = let open R in let bv : binder_view = { sort = elab_term b.binder_ty; ppname = b.binder_ppname.name; qual = Q_Explicit; attrs = [] } in pack_binder bv in let abstraction = L.fold_right (fun b (tv:host_term) -> let b = as_binder b in R.pack_ln (R.Tv_Abs b tv)) bs tv in let inst_abstraction, _ = PC.instantiate_term_implicits g (tm_fstar abstraction v.range) in match inst_abstraction.t with | Tm_FStar t -> refl_abs_binders t [] | _ -> T.fail "Impossible: instantiated abstraction is not embedded F* term, please file a bug-report" let rec open_binders (g:env) (bs:list binder) (uvs:env { disjoint uvs g }) (v:term) (body:st_term) : T.Tac (uvs:env { disjoint uvs g } & term & st_term) = match bs with | [] -> (| uvs, v, body |) | b::bs -> // these binders are only lax checked so far let _ = PC.check_universe (push_env g uvs) b.binder_ty in let x = fresh (push_env g uvs) in let ss = [ DT 0 (tm_var {nm_index=x;nm_ppname=b.binder_ppname}) ] in let bs = L.mapi (fun i b -> assume (i >= 0); subst_binder b (shift_subst_n i ss)) bs in let v = subst_term v (shift_subst_n (L.length bs) ss) in let body = subst_st_term body (shift_subst_n (L.length bs) ss) in open_binders g bs (push_binding uvs x b.binder_ppname b.binder_ty) v body let closing (bs:list (ppname & var & typ)) : subst = L.fold_right (fun (_, x, _) (n, ss) -> n+1, (ND x n)::ss ) bs (0, []) |> snd let rec close_binders (bs:list (ppname & var & typ)) : Tot (list binder) (decreases L.length bs) = match bs with | [] -> [] | (name, x, t)::bs -> let bss = L.mapi (fun n (n1, x1, t1) -> assume (n >= 0); n1, x1, subst_term t1 [ND x n]) bs in let b = mk_binder_ppname t name in assume (L.length bss == L.length bs); b::(close_binders bss) let unfold_defs (g:env) (defs:option (list string)) (t:term) : T.Tac term = let t = elab_term t in let head, _ = T.collect_app t in match R.inspect_ln head with | R.Tv_FVar fv | R.Tv_UInst fv _ -> ( let head = String.concat "." (R.inspect_fv fv) in let fully = match defs with | Some defs -> defs | None -> [] in let rt = RU.unfold_def (fstar_env g) head fully t in let rt = option_must rt (Printf.sprintf "unfolding %s returned None" (T.term_to_string t)) in let ty = option_must (readback_ty rt) (Printf.sprintf "error in reading back the unfolded term %s" (T.term_to_string rt)) in debug_log g (fun _ -> Printf.sprintf "Unfolded %s to F* term %s and readback as %s" (T.term_to_string t) (T.term_to_string rt) (P.term_to_string ty)); ty ) | _ -> fail g (Some (RU.range_of_term t)) (Printf.sprintf "Cannot unfold %s, the head is not an fvar" (T.term_to_string t)) let check_unfoldable g (v:term) : T.Tac unit = match v.t with | Tm_FStar _ -> () | _ -> fail g (Some v.range) (Printf.sprintf "`fold` and `unfold` expect a single user-defined predicate as an argument, \ but %s is a primitive term that cannot be folded or unfolded" (P.term_to_string v)) let visit_and_rewrite (p: (R.term & R.term)) (t:term) : T.Tac term = let open FStar.Reflection.V2.TermEq in let lhs, rhs = p in let visitor (t:R.term) : T.Tac R.term = if term_eq t lhs then rhs else t in match R.inspect_ln lhs with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in assume (is_host_term rhs); subst_term t [NT nv.uniq { t = Tm_FStar rhs; range = t.range }] ) | _ -> let rec aux (t:term) : T.Tac term = match t.t with | Tm_Emp | Tm_VProp | Tm_Inames | Tm_EmpInames | Tm_Inames | Tm_Unknown -> t | Tm_Inv i -> { t with t = Tm_Inv (aux i) } | Tm_AddInv i is -> { t with t = Tm_AddInv (aux i) (aux is) } | Tm_Pure p -> { t with t = Tm_Pure (aux p) } | Tm_Star l r -> { t with t = Tm_Star (aux l) (aux r) } | Tm_ExistsSL u b body -> { t with t = Tm_ExistsSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_ForallSL u b body -> { t with t = Tm_ForallSL u { b with binder_ty=aux b.binder_ty} (aux body) } | Tm_FStar h -> let h = FStar.Tactics.Visit.visit_tm visitor h in assume (is_host_term h); { t with t=Tm_FStar h } in aux t let visit_and_rewrite_conjuncts (p: (R.term & R.term)) (tms:list term) : T.Tac (list term) = T.map (visit_and_rewrite p) tms let visit_and_rewrite_conjuncts_all (p: list (R.term & R.term)) (goal:term) : T.Tac (term & term) = let tms = Pulse.Typing.Combinators.vprop_as_list goal in let tms' = T.fold_left (fun tms p -> visit_and_rewrite_conjuncts p tms) tms p in assume (L.length tms' == L.length tms); let lhs, rhs = T.fold_left2 (fun (lhs, rhs) t t' -> if eq_tm t t' then lhs, rhs else (t::lhs, t'::rhs)) ([], []) tms tms' in Pulse.Typing.Combinators.list_as_vprop lhs, Pulse.Typing.Combinators.list_as_vprop rhs let disjoint (dom:list var) (cod:Set.set var) = L.for_all (fun d -> not (Set.mem d cod)) dom let rec as_subst (p : list (term & term)) (out:list subst_elt) (domain:list var) (codomain:Set.set var) : option (list subst_elt) = match p with | [] -> if disjoint domain codomain then Some out else None | (e1, e2)::p -> ( match e1.t with | Tm_FStar e1 -> ( match R.inspect_ln e1 with | R.Tv_Var n -> ( let nv = R.inspect_namedv n in as_subst p (NT nv.uniq e2::out) (nv.uniq ::domain ) (Set.union codomain (freevars e2)) ) | _ -> None ) | _ -> None ) let rewrite_all (g:env) (p: list (term & term)) (t:term) : T.Tac (term & term) = match as_subst p [] [] Set.empty with | Some s -> t, subst_term t s | _ -> let p : list (R.term & R.term) = T.map (fun (e1, e2) -> elab_term (fst (Pulse.Checker.Pure.instantiate_term_implicits g e1)), elab_term (fst (Pulse.Checker.Pure.instantiate_term_implicits g e2))) p in let lhs, rhs = visit_and_rewrite_conjuncts_all p t in debug_log g (fun _ -> Printf.sprintf "Rewrote %s to %s" (P.term_to_string lhs) (P.term_to_string rhs)); lhs, rhs let check_renaming (g:env) (pre:term) (st:st_term { match st.term with | Tm_ProofHintWithBinders { hint_type = RENAME _ } -> true | _ -> false }) : T.Tac st_term = let Tm_ProofHintWithBinders ht = st.term in let { hint_type=RENAME { pairs; goal }; binders=bs; t=body } = ht in match bs, goal with | _::_, None -> //if there are binders, we must have a goal fail g (Some st.range) "A renaming with binders must have a goal (with xs. rename ... in goal)" | _::_, Some goal -> //rewrite it as // with bs. assert goal; // rename [pairs] in goal; // ... let body = {st with term = Tm_ProofHintWithBinders { ht with binders = [] }} in { st with term = Tm_ProofHintWithBinders { hint_type=ASSERT { p = goal }; binders=bs; t=body } } | [], None -> // if there is no goal, take the goal to be the full current pre let lhs, rhs = rewrite_all g pairs pre in let t = { st with term = Tm_Rewrite { t1 = lhs; t2 = rhs } } in { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } | [], Some goal -> ( let goal, _ = PC.instantiate_term_implicits g goal in let lhs, rhs = rewrite_all g pairs goal in let t = { st with term = Tm_Rewrite { t1 = lhs; t2 = rhs } } in { st with term = Tm_Bind { binder = as_binder tm_unit; head = t; body } } ) let check_wild (g:env) (pre:term) (st:st_term { head_wild st }) : T.Tac st_term = let Tm_ProofHintWithBinders ht = st.term in let { binders=bs; t=body } = ht in match bs with | [] -> fail g (Some st.range) "A wildcard must have at least one binder" | _ -> let vprops = Pulse.Typing.Combinators.vprop_as_list pre in let ex, rest = List.Tot.partition (fun (v:vprop) -> Tm_ExistsSL? v.t) vprops in match ex with | [] | _::_::_ -> fail g (Some st.range) "Binding names with a wildcard requires exactly one existential quantifier in the goal" | [ex] -> let k = List.Tot.length bs in let rec peel_binders (n:nat) (t:term) : T.Tac st_term = if n = 0 then ( let ex_body = t in { st with term = Tm_ProofHintWithBinders { ht with hint_type = ASSERT { p = ex_body } }} ) else ( match t.t with | Tm_ExistsSL u b body -> peel_binders (n-1) body | _ -> fail g (Some st.range) (Printf.sprintf "Expected an existential quantifier with at least %d binders; but only found %s with %d binders" k (show ex) (k - n)) ) in peel_binders k ex // // v is a partially applied vprop with type t // add uvars for the remaining arguments // let rec add_rem_uvs (g:env) (t:typ) (uvs:env { Env.disjoint g uvs }) (v:vprop) : T.Tac (uvs:env { Env.disjoint g uvs } & vprop) = match is_arrow t with | None -> (| uvs, v |) | Some (b, qopt, c) -> let x = fresh (push_env g uvs) in let ct = open_comp_nv c (b.binder_ppname, x) in let uvs = Env.push_binding uvs x b.binder_ppname b.binder_ty in let v = tm_pureapp v qopt (tm_var {nm_index = x; nm_ppname = b.binder_ppname}) in add_rem_uvs g (comp_res ct) uvs v
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Naming.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Show.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Stubs.Pprint.fsti.checked", "FStar.String.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Checker.AssertWithBinders.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Show", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Typing.Env", "short_module": "Env" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover", "short_module": "Prover" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Syntax.Naming", "short_module": "N" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "PC" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Pulse.Typing.Env", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> pre: Pulse.Syntax.Base.term -> pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop -> post_hint: Pulse.Typing.post_hint_opt g -> res_ppname: Pulse.Syntax.Base.ppname -> st: Pulse.Syntax.Base.st_term{Tm_ProofHintWithBinders? (Mkst_term?.term st)} -> check: Pulse.Checker.Base.check_t -> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.post_hint_opt", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.st_term", "Prims.b2t", "Pulse.Syntax.Base.uu___is_Tm_ProofHintWithBinders", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Checker.Base.check_t", "Pulse.Syntax.Base.proof_hint_type", "Prims.list", "Pulse.Syntax.Base.binder", "Pulse.Checker.Base.checker_result_t", "Pulse.Checker.AssertWithBinders.check_wild", "Pulse.Syntax.Base.range", "Pulse.Typing.Env.fail_doc_env", "FStar.Pervasives.Native.Some", "FStar.Stubs.Pprint.document", "Prims.Cons", "Prims.Nil", "FStar.Stubs.Pprint.op_Hat_Hat", "Pulse.PP.text", "Pulse.PP.indent", "Pulse.PP.pp", "Pulse.PP.uu___44", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "Pulse.Checker.AssertWithBinders.check_renaming", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Syntax.Base.as_binder", "Pulse.Typing.tm_unit", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag", "Pulse.Syntax.Base.Tm_Rewrite", "Pulse.Syntax.Base.Mkst_term'__Tm_Rewrite__payload", "Pulse.Syntax.Base.Tm_ProofHintWithBinders", "Pulse.Syntax.Base.Mkst_term'__Tm_ProofHintWithBinders__payload", "Pulse.Syntax.Base.ASSERT", "Pulse.Syntax.Base.Mkproof_hint_type__ASSERT__payload", "Pulse.Typing.Env.disjoint", "Pulse.Typing.Env.push_env", "Prims.l_and", "Pulse.Typing.Env.env_extends", "Pulse.Checker.Prover.Substs.nt_substs", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "Pulse.Checker.Prover.Substs.well_typed_nt_substs", "Pulse.Checker.Base.continuation_elaborator", "Pulse.Checker.Prover.Base.op_Star", "Pulse.Checker.Prover.Substs.nt_subst_term", "Pulse.Syntax.Base.var", "FStar.Pervasives.dtuple3", "Pulse.Syntax.Base.universe", "Pulse.Syntax.Base.typ", "Pulse.Typing.universe_of", "Prims.dtuple2", "Pulse.Syntax.Base.tm_star", "FStar.Pervasives.dfst", "Pulse.Checker.Base.checker_result_inv", "FStar.Pervasives.Mkdtuple5", "Pulse.Checker.Base.k_elab_trans", "Pulse.RuntimeUtils.magic", "Pulse.Checker.Prover.Substs.nt_subst_st_term", "FStar.Pervasives.dtuple5", "Pulse.Checker.Prover.prove", "Pulse.Checker.Pure.check_vprop", "FStar.Pervasives.Native.Mktuple2", "Pulse.Checker.AssertWithBinders.open_binders", "Pulse.Typing.Env.mk_env", "Pulse.Typing.Env.fstar_env", "Pulse.Checker.AssertWithBinders.infer_binder_types", "Prims.string", "Pulse.Syntax.Base.tm_fstar", "Pulse.Syntax.Base.as_effect_hint", "Pulse.Syntax.Base.STT_Ghost", "Pulse.Checker.AssertWithBinders.close_binders", "Pulse.Syntax.Naming.subst_st_term", "Pulse.Syntax.Naming.subst_term", "Pulse.Syntax.Naming.subst", "Pulse.Checker.AssertWithBinders.closing", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.rev", "Pulse.Typing.Env.bindings_with_ppname", "Pulse.Syntax.Base.proof_hint_type__UNFOLD__payload", "Pulse.Checker.AssertWithBinders.unfold_defs", "FStar.Pervasives.Native.None", "Pulse.Checker.AssertWithBinders.add_rem_uvs", "Pulse.Checker.Pure.instantiate_term_implicits", "Prims.unit", "Pulse.Checker.AssertWithBinders.check_unfoldable", "Pulse.Syntax.Base.st_term'", "Prims.eq2", "Pulse.Typing.Env.push_context" ]
[]
false
true
false
false
false
let check (g: env) (pre: term) (pre_typing: tot_typing g pre tm_vprop) (post_hint: post_hint_opt g) (res_ppname: ppname) (st: st_term{Tm_ProofHintWithBinders? st.term}) (check: check_t) : T.Tac (checker_result_t g pre post_hint) =
let g = push_context g "check_assert" st.range in let Tm_ProofHintWithBinders { hint_type = hint_type ; binders = bs ; t = body } = st.term in match hint_type with | WILD -> let st = check_wild g pre st in check g pre pre_typing post_hint res_ppname st | SHOW_PROOF_STATE r -> let open FStar.Stubs.Pprint in let open Pulse.PP in let msg = [text "Current context:" ^^ indent (pp pre)] in fail_doc_env true g (Some r) msg | RENAME { pairs = pairs ; goal = goal } -> let st = check_renaming g pre st in check g pre pre_typing post_hint res_ppname st | REWRITE { t1 = t1 ; t2 = t2 } -> (match bs with | [] -> let t = { st with term = Tm_Rewrite ({ t1 = t1; t2 = t2 }) } in check g pre pre_typing post_hint res_ppname ({ st with term = Tm_Bind ({ binder = as_binder tm_unit; head = t; body = body }) }) | _ -> let t = { st with term = Tm_Rewrite ({ t1 = t1; t2 = t2 }) } in let body = { st with term = Tm_Bind ({ binder = as_binder tm_unit; head = t; body = body }) } in let st = { st with term = Tm_ProofHintWithBinders ({ hint_type = ASSERT ({ p = t1 }); binders = bs; t = body }) } in check g pre pre_typing post_hint res_ppname st) | ASSERT { p = v } -> let bs = infer_binder_types g bs v in let (| uvs , v_opened , body_opened |) = open_binders g bs (mk_env (fstar_env g)) v body in let v, body = v_opened, body_opened in let (| v , d |) = PC.check_vprop (push_env g uvs) v in let (| g1 , nts , _ , pre' , k_frame |) = Prover.prove pre_typing uvs d in let (| x , x_ty , pre'' , g2 , k |) = check g1 (tm_star (PS.nt_subst_term v nts) pre') (RU.magic ()) post_hint res_ppname (PS.nt_subst_st_term body nts) in (| x, x_ty, pre'', g2, k_elab_trans k_frame k |) | UNFOLD { names = names ; p = v } | FOLD { names = names ; p = v } -> let (| uvs , v_opened , body_opened |) = let bs = infer_binder_types g bs v in open_binders g bs (mk_env (fstar_env g)) v body in check_unfoldable g v; let v_opened, t_rem = PC.instantiate_term_implicits (push_env g uvs) v_opened in let uvs, v_opened = let (| uvs_rem , v_opened |) = add_rem_uvs (push_env g uvs) t_rem (mk_env (fstar_env g)) v_opened in push_env uvs uvs_rem, v_opened in let lhs, rhs = match hint_type with | UNFOLD _ -> v_opened, unfold_defs (push_env g uvs) None v_opened | FOLD { names = ns } -> unfold_defs (push_env g uvs) ns v_opened, v_opened in let uvs_bs = uvs |> bindings_with_ppname |> L.rev in let uvs_closing = uvs_bs |> closing in let lhs = subst_term lhs uvs_closing in let rhs = subst_term rhs uvs_closing in let body = subst_st_term body_opened uvs_closing in let bs = close_binders uvs_bs in let rw = { term = Tm_Rewrite ({ t1 = lhs; t2 = rhs }); range = st.range; effect_tag = as_effect_hint STT_Ghost } in let st = { term = Tm_Bind ({ binder = as_binder (tm_fstar (`unit) st.range); head = rw; body = body }); range = st.range; effect_tag = body.effect_tag } in let st = match bs with | [] -> st | _ -> { term = Tm_ProofHintWithBinders ({ hint_type = ASSERT ({ p = lhs }); binders = bs; t = st }); range = st.range; effect_tag = st.effect_tag } in check g pre pre_typing post_hint res_ppname st
false
Lib.Sequence.fst
Lib.Sequence.member
val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool
val member: #a:eqtype -> #len: size_nat -> a -> lseq a len -> Tot bool
let member #a #len x l = Seq.count x l > 0
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 37, "start_col": 0, "start_line": 37 }
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
{ "checked_file": "/", "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" }
[ { "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", "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 } ]
{ "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" }
false
x: a -> l: Lib.Sequence.lseq a len -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.op_GreaterThan", "FStar.Seq.Properties.count", "Prims.bool" ]
[]
false
false
false
false
false
let member #a #len x l =
Seq.count x l > 0
false
Lib.Sequence.fst
Lib.Sequence.map2_inner
val map2_inner : f: (_: a -> _: b -> c) -> s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq b len -> i: Lib.IntTypes.size_nat{i < len} -> c
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]
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 118, "start_col": 0, "start_line": 116 }
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])
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
f: (_: a -> _: b -> c) -> s1: Lib.Sequence.lseq a len -> s2: Lib.Sequence.lseq b len -> i: Lib.IntTypes.size_nat{i < len} -> c
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.op_String_Access" ]
[]
false
false
false
false
false
let map2_inner (#a #b #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 ]
false
Lib.Sequence.fst
Lib.Sequence.map_inner
val map_inner : f: (_: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
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]
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 107, "start_col": 0, "start_line": 105 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
f: (_: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.op_String_Access" ]
[]
false
false
false
false
false
let map_inner (#a #b: Type) (#len: size_nat) (f: (a -> Tot b)) (s: lseq a len) (i: size_nat{i < len}) =
f s.[ i ]
false
Hacl.Impl.K256.Verify.fst
Hacl.Impl.K256.Verify.ecdsa_verify_avoid_finv
val ecdsa_verify_avoid_finv: p:point -> r:QA.qelem -> Stack bool (requires fun h -> live h p /\ live h r /\ disjoint p r /\ point_inv h p /\ QA.qe_lt_q h r /\ 0 < QA.qas_nat h r /\ not (S.is_proj_point_at_inf (point_eval h p))) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let (_X, _Y, _Z) = point_eval h0 p in b <==> (S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r)))
val ecdsa_verify_avoid_finv: p:point -> r:QA.qelem -> Stack bool (requires fun h -> live h p /\ live h r /\ disjoint p r /\ point_inv h p /\ QA.qe_lt_q h r /\ 0 < QA.qas_nat h r /\ not (S.is_proj_point_at_inf (point_eval h p))) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let (_X, _Y, _Z) = point_eval h0 p in b <==> (S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r)))
let ecdsa_verify_avoid_finv p r = let h0 = ST.get () in let x, y, z = getx p, gety p, getz p in push_frame (); let r_bytes = create 32ul (u8 0) in let r_fe = create_felem () in let tmp_q = create_felem () in let tmp_x = create_felem () in QA.store_qelem r_bytes r; load_felem r_fe r_bytes; let h1 = ST.get () in assert (modifies (loc r_fe) h0 h1); //assert (inv_fully_reduced h1 r_fe); //assert (as_nat h1 r_fe == qas_nat h1 r); let h2 = ST.get () in fnormalize tmp_x x; let h3 = ST.get () in assert (modifies (loc tmp_x) h2 h3); BL.normalize5_lemma (1,1,1,1,2) (as_felem5 h2 x); //assert (inv_fully_reduced h3 tmp_x); //assert (inv_lazy_reduced2 h3 z); let is_rz_x = fmul_eq_vartime r_fe z tmp_x in //assert (is_rz_x == (S.fmul (as_nat h3 r_fe) (feval h3 z) = as_nat h3 tmp_x)); let res : bool = if not is_rz_x then begin let is_r_lt_p_m_q = is_felem_lt_prime_minus_order_vartime r_fe in if is_r_lt_p_m_q then begin assert (as_nat h1 r_fe < S.prime - S.q); make_u52_5 tmp_q (make_order_k256 ()); let h4 = ST.get () in BL.add5_lemma (1,1,1,1,1) (1,1,1,1,1) (as_felem5 h4 r_fe) (as_felem5 h4 tmp_q); fadd tmp_q r_fe tmp_q; fmul_eq_vartime tmp_q z tmp_x end //assert (is_rqz_x == (S.fmul (feval h5 tmp) (feval h5 z) = as_nat h5 tmp_x)); else false end else true in let h4 = ST.get () in assert (modifies (loc tmp_q) h3 h4); pop_frame (); KL.ecdsa_verify_avoid_finv (point_eval h0 p) (QA.qas_nat h0 r); assert (res <==> (S.fmul (feval h0 x) (S.finv (feval h0 z)) % S.q = QA.qas_nat h0 r)); let h5 = ST.get () in assert (modifies0 h0 h5); res
{ "file_name": "code/k256/Hacl.Impl.K256.Verify.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 134, "start_col": 0, "start_line": 84 }
module Hacl.Impl.K256.Verify open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module S = Spec.K256 module KL = Spec.K256.Lemmas open Hacl.K256.Field open Hacl.Impl.K256.Point open Hacl.Impl.K256.PointMul open Hacl.Impl.K256.GLV module QA = Hacl.K256.Scalar module QI = Hacl.Impl.K256.Qinv module BL = Hacl.Spec.K256.Field52.Lemmas module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_verify_get_u12 (u1 u2 r s z: QA.qelem) : Stack unit (requires fun h -> live h r /\ live h s /\ live h z /\ live h u1 /\ live h u2 /\ disjoint u1 u2 /\ disjoint u1 z /\ disjoint u1 r /\ disjoint u1 s /\ disjoint u2 z /\ disjoint u2 r /\ disjoint u2 s /\ QA.qas_nat h s < S.q /\ QA.qas_nat h z < S.q /\ QA.qas_nat h r < S.q) (ensures fun h0 _ h1 -> modifies (loc u1 |+| loc u2) h0 h1 /\ (let sinv = S.qinv (QA.qas_nat h0 s) in QA.qas_nat h1 u1 == QA.qas_nat h0 z * sinv % S.q /\ QA.qas_nat h1 u2 == QA.qas_nat h0 r * sinv % S.q)) let ecdsa_verify_get_u12 u1 u2 r s z = push_frame (); let sinv = QA.create_qelem () in QI.qinv sinv s; QA.qmul u1 z sinv; QA.qmul u2 r sinv; pop_frame () val fmul_eq_vartime (r z x: felem) : Stack bool (requires fun h -> live h r /\ live h z /\ live h x /\ eq_or_disjoint r z /\ felem_fits5 (as_felem5 h r) (2,2,2,2,2) /\ as_nat h r < S.prime /\ inv_lazy_reduced2 h z /\ inv_fully_reduced h x) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (S.fmul (as_nat h0 r) (feval h0 z) = as_nat h0 x)) [@CInline] let fmul_eq_vartime r z x = push_frame (); let tmp = create_felem () in fmul tmp r z; let h1 = ST.get () in fnormalize tmp tmp; let h2 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (as_felem5 h1 tmp); assert (inv_fully_reduced h2 tmp); let b = is_felem_eq_vartime tmp x in pop_frame (); b inline_for_extraction noextract val ecdsa_verify_avoid_finv: p:point -> r:QA.qelem -> Stack bool (requires fun h -> live h p /\ live h r /\ disjoint p r /\ point_inv h p /\ QA.qe_lt_q h r /\ 0 < QA.qas_nat h r /\ not (S.is_proj_point_at_inf (point_eval h p))) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ (let (_X, _Y, _Z) = point_eval h0 p in b <==> (S.fmul _X (S.finv _Z) % S.q = QA.qas_nat h0 r)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.Qinv.fst.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.GLV.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.K256.Verify.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "QA" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Field", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Hacl.Impl.K256.Point.point -> r: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "Hacl.K256.Field.felem", "Prims.unit", "Prims._assert", "Lib.Buffer.modifies0", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.l_iff", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Spec.K256.PointOps.fmul", "Hacl.K256.Field.feval", "Spec.K256.PointOps.finv", "Spec.K256.PointOps.q", "Hacl.K256.Scalar.qas_nat", "Spec.K256.Lemmas.ecdsa_verify_avoid_finv", "Hacl.Impl.K256.Point.point_eval", "FStar.HyperStack.ST.pop_frame", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Prims.op_Negation", "Hacl.Impl.K256.Verify.fmul_eq_vartime", "Hacl.K256.Field.fadd", "Hacl.Spec.K256.Field52.Lemmas.add5_lemma", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.K256.Field.as_felem5", "Hacl.K256.Field.make_u52_5", "Hacl.K256.Field.make_order_k256", "Prims.op_LessThan", "Hacl.K256.Field.as_nat", "Prims.op_Subtraction", "Spec.K256.PointOps.prime", "Hacl.K256.Field.is_felem_lt_prime_minus_order_vartime", "Hacl.Spec.K256.Field52.Lemmas.normalize5_lemma", "Hacl.K256.Field.fnormalize", "Hacl.K256.Field.load_felem", "Hacl.K256.Scalar.store_qelem", "Hacl.K256.Field.create_felem", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Hacl.Impl.K256.Point.getz", "Hacl.Impl.K256.Point.gety", "Hacl.Impl.K256.Point.getx" ]
[]
false
true
false
false
false
let ecdsa_verify_avoid_finv p r =
let h0 = ST.get () in let x, y, z = getx p, gety p, getz p in push_frame (); let r_bytes = create 32ul (u8 0) in let r_fe = create_felem () in let tmp_q = create_felem () in let tmp_x = create_felem () in QA.store_qelem r_bytes r; load_felem r_fe r_bytes; let h1 = ST.get () in assert (modifies (loc r_fe) h0 h1); let h2 = ST.get () in fnormalize tmp_x x; let h3 = ST.get () in assert (modifies (loc tmp_x) h2 h3); BL.normalize5_lemma (1, 1, 1, 1, 2) (as_felem5 h2 x); let is_rz_x = fmul_eq_vartime r_fe z tmp_x in let res:bool = if not is_rz_x then let is_r_lt_p_m_q = is_felem_lt_prime_minus_order_vartime r_fe in if is_r_lt_p_m_q then (assert (as_nat h1 r_fe < S.prime - S.q); make_u52_5 tmp_q (make_order_k256 ()); let h4 = ST.get () in BL.add5_lemma (1, 1, 1, 1, 1) (1, 1, 1, 1, 1) (as_felem5 h4 r_fe) (as_felem5 h4 tmp_q); fadd tmp_q r_fe tmp_q; fmul_eq_vartime tmp_q z tmp_x) else false else true in let h4 = ST.get () in assert (modifies (loc tmp_q) h3 h4); pop_frame (); KL.ecdsa_verify_avoid_finv (point_eval h0 p) (QA.qas_nat h0 r); assert (res <==> (S.fmul (feval h0 x) (S.finv (feval h0 z)) % S.q = QA.qas_nat h0 r)); let h5 = ST.get () in assert (modifies0 h0 h5); res
false
Lib.Sequence.fst
Lib.Sequence.for_all
val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool
val for_all:#a:Type -> #len:size_nat -> (a -> Tot bool) -> lseq a len -> bool
let for_all #a #len f x = Seq.for_all f x
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 123, "start_col": 0, "start_line": 123 }
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)
{ "checked_file": "/", "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" }
[ { "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", "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 } ]
{ "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" }
false
f: (_: a -> Prims.bool) -> x: Lib.Sequence.lseq a len -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.bool", "Lib.Sequence.lseq", "FStar.Seq.Properties.for_all" ]
[]
false
false
false
false
false
let for_all #a #len f x =
Seq.for_all f x
false
Lib.Sequence.fst
Lib.Sequence.concat
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)})
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 = Seq.append s0 s1
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 13, "start_col": 0, "start_line": 13 }
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
{ "checked_file": "/", "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" }
[ { "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", "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 } ]
{ "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" }
false
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) }
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let concat #a #len0 #len1 s0 s1 =
Seq.append s0 s1
false
Lib.Sequence.fst
Lib.Sequence.to_list
val to_list: #a:Type -> s:seq a -> Tot (l:list a{List.Tot.length l = length s /\ l == 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 = Seq.seq_to_list s
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 15, "start_col": 0, "start_line": 15 }
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
{ "checked_file": "/", "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" }
[ { "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", "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 } ]
{ "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" }
false
s: Lib.Sequence.seq a -> l: Prims.list a {FStar.List.Tot.Base.length l = Lib.Sequence.length s /\ l == FStar.Seq.Base.seq_to_list s}
Prims.Tot
[ "total" ]
[]
[ "Lib.Sequence.seq", "FStar.Seq.Base.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" ]
[]
false
false
false
false
false
let to_list #a s =
Seq.seq_to_list s
false
LowParse.Low.IfThenElse.fst
LowParse.Low.IfThenElse.accessor_ifthenelse_payload
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))
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)) = fun #rrel #rel -> accessor_ifthenelse_payload' s j b #rrel #rel
{ "file_name": "src/lowparse/LowParse.Low.IfThenElse.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 65, "end_line": 292, "start_col": 0, "start_line": 286 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: 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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Lib.Sequence.fst
Lib.Sequence.index
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})
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 = Seq.index s n
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 9, "start_col": 0, "start_line": 9 }
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'"
{ "checked_file": "/", "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" }
[ { "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", "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 } ]
{ "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" }
false
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}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Lib.Sequence.lseq", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.index", "Prims.eq2", "Lib.Sequence.to_seq" ]
[]
false
false
false
false
false
let index #a #len s n =
Seq.index s n
false
Lib.Sequence.fst
Lib.Sequence.create
val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)})
val create: #a:Type -> len:size_nat -> init:a -> Tot (s:lseq a len{to_seq s == Seq.create len init /\ (forall (i:nat). {:pattern (index s i)} i < len ==> index s i == init)})
let create #a len init = Seq.create #a len init
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 11, "start_col": 0, "start_line": 11 }
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
{ "checked_file": "/", "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" }
[ { "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", "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 } ]
{ "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" }
false
len: Lib.IntTypes.size_nat -> init: a -> s: Lib.Sequence.lseq a len { Lib.Sequence.to_seq s == FStar.Seq.Base.create len init /\ (forall (i: Prims.nat). {:pattern Lib.Sequence.index s i} i < len ==> Lib.Sequence.index s i == init) }
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "FStar.Seq.Base.create", "Lib.Sequence.lseq", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.index" ]
[]
false
false
false
false
false
let create #a len init =
Seq.create #a len init
false
Lib.Sequence.fst
Lib.Sequence.mapi_inner
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
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]
{ "file_name": "lib/Lib.Sequence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 99, "start_col": 0, "start_line": 97 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
f: (i: Prims.nat{i < len} -> _: a -> b) -> s: Lib.Sequence.lseq a len -> i: Lib.IntTypes.size_nat{i < len} -> b
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.op_String_Access" ]
[]
false
false
false
false
false
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}) =
f i s.[ i ]
false