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.NamedView.fst | FStar.Tactics.NamedView.inspect_sigelt | val inspect_sigelt (s : sigelt) : Tac named_sigelt_view | val inspect_sigelt (s : sigelt) : Tac named_sigelt_view | let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 651,
"start_col": 0,
"start_line": 648
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Stubs.Reflection.Types.sigelt
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_sigelt_view | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.Types.sigelt",
"FStar.Tactics.NamedView.open_sigelt_view",
"FStar.Tactics.NamedView.named_sigelt_view",
"FStar.Stubs.Reflection.V2.Data.sigelt_view",
"FStar.Stubs.Reflection.V2.Builtins.inspect_sigelt"
] | [] | false | true | false | false | false | let inspect_sigelt (s: sigelt) : Tac named_sigelt_view =
| let sv = R.inspect_sigelt s in
open_sigelt_view sv | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.tcc | val tcc (e:env) (t:term) : Tac comp | val tcc (e:env) (t:term) : Tac comp | let tcc (e:env) (t:term) : Tac comp =
let c : R.comp = Stubs.Tactics.V2.Builtins.tcc e t in
R.inspect_comp c | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 660,
"start_col": 0,
"start_line": 658
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ
[@@plugin]
let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv
[@@plugin]
let pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
let sv = close_sigelt_view sv in
R.pack_sigelt sv | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | e: FStar.Stubs.Reflection.Types.env -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.comp | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.Types.env",
"FStar.Tactics.NamedView.term",
"FStar.Stubs.Reflection.V2.Builtins.inspect_comp",
"FStar.Tactics.NamedView.comp",
"FStar.Stubs.Reflection.Types.comp",
"FStar.Stubs.Tactics.V2.Builtins.tcc"
] | [] | false | true | false | false | false | let tcc (e: env) (t: term) : Tac comp =
| let c:R.comp = Stubs.Tactics.V2.Builtins.tcc e t in
R.inspect_comp c | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.close_match_returns_ascription | val close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription | val close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription | let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq)) | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 408,
"start_col": 0,
"start_line": 392
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | mra: FStar.Tactics.NamedView.match_returns_ascription
-> FStar.Stubs.Reflection.Types.match_returns_ascription | Prims.Tot | [
"total"
] | [] | [
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.NamedView.binder",
"FStar.Pervasives.either",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.Types.binder",
"FStar.Pervasives.Native.tuple3",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.Types.comp",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.snd",
"FStar.Tactics.NamedView.close_term",
"FStar.Pervasives.Inl",
"FStar.Pervasives.Inr",
"FStar.Stubs.Reflection.V2.Builtins.pack_comp",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_comp",
"FStar.Tactics.NamedView.close_binder",
"FStar.Stubs.Reflection.Types.match_returns_ascription"
] | [] | false | false | false | true | false | let close_match_returns_ascription (mra: match_returns_ascription) : R.match_returns_ascription =
| let nb, (ct, topt, use_eq) = mra in
let b = close_binder nb in
let ct =
match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq)) | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.pack_sigelt | val pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt | val pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt | let pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
let sv = close_sigelt_view sv in
R.pack_sigelt sv | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 656,
"start_col": 0,
"start_line": 654
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ
[@@plugin]
let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | sv: FStar.Tactics.NamedView.named_sigelt_view{~(Unk? sv)}
-> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.sigelt | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.NamedView.named_sigelt_view",
"Prims.l_not",
"Prims.b2t",
"FStar.Tactics.NamedView.uu___is_Unk",
"FStar.Stubs.Reflection.V2.Builtins.pack_sigelt",
"FStar.Stubs.Reflection.Types.sigelt",
"FStar.Stubs.Reflection.V2.Data.sigelt_view",
"FStar.Stubs.Reflection.V2.Data.uu___is_Unk",
"FStar.Tactics.NamedView.close_sigelt_view"
] | [] | false | true | false | false | false | let pack_sigelt (sv: named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
| let sv = close_sigelt_view sv in
R.pack_sigelt sv | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.open_pat | val open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t) | val open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t) | let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 324,
"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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'') | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: FStar.Stubs.Reflection.V2.Data.pattern -> s: FStar.Stubs.Syntax.Syntax.subst_t
-> FStar.Tactics.Effect.Tac (FStar.Tactics.NamedView.pattern * FStar.Stubs.Syntax.Syntax.subst_t) | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.V2.Data.pattern",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Stubs.Reflection.V2.Data.vconst",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.pattern",
"FStar.Tactics.NamedView.Pat_Constant",
"FStar.Tactics.NamedView.Mkpattern__Pat_Constant__payload",
"FStar.Pervasives.Native.tuple2",
"FStar.Sealed.sealed",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Data.ppname_t",
"FStar.Tactics.NamedView.Pat_Var",
"FStar.Tactics.NamedView.Mkpattern__Pat_Var__payload",
"FStar.Sealed.seal",
"FStar.Stubs.Reflection.Types.typ",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Stubs.Reflection.Types.namedv",
"FStar.Stubs.Reflection.V2.Builtins.pack_namedv",
"FStar.Tactics.NamedView.namedv",
"FStar.Stubs.Reflection.V2.Data.Mknamedv_view",
"Prims.nat",
"FStar.Stubs.Tactics.V2.Builtins.fresh",
"FStar.Stubs.Reflection.V2.Builtins.subst_term",
"FStar.Tactics.Unseal.unseal",
"FStar.Stubs.Reflection.Types.fv",
"FStar.Pervasives.Native.option",
"FStar.Stubs.Reflection.V2.Data.universes",
"Prims.list",
"Prims.bool",
"FStar.Tactics.NamedView.Pat_Cons",
"FStar.Tactics.NamedView.Mkpattern__Pat_Cons__payload",
"FStar.List.Tot.Base.rev",
"FStar.Tactics.Util.fold_left",
"FStar.Tactics.NamedView.open_pat",
"Prims.Nil",
"FStar.Tactics.NamedView.Pat_Dot_Term",
"FStar.Tactics.NamedView.Mkpattern__Pat_Dot_Term__payload",
"FStar.Pervasives.Native.None",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Some"
] | [
"recursion"
] | false | true | false | false | false | let rec open_pat (p: R.pattern) (s: subst_t) : Tac (pattern & subst_t) =
| match p with
| R.Pat_Constant c -> Pat_Constant ({ c = c }), s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv:namedv = { uniq = fresh (); sort = seal sort; ppname = n } in
let nv = pack_namedv nvv in
Pat_Var ({ v = nvv; sort = seal sort }), (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s =
fold_left (fun (pats, s) (pat, b) ->
let pat, s' = open_pat pat s in
((pat, b) :: pats, s'))
([], s)
subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons ({ head = head; univs = univs; subpats = subpats }), s
| R.Pat_Dot_Term None -> Pat_Dot_Term ({ t = None }), s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term ({ t = Some t }), s | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.open_match_returns_ascription | val open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription | val open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription | let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq)) | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 389,
"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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t') | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | mra: FStar.Stubs.Reflection.Types.match_returns_ascription
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.match_returns_ascription | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.Types.match_returns_ascription",
"FStar.Stubs.Reflection.Types.binder",
"FStar.Pervasives.either",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.Types.comp",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.binder",
"FStar.Pervasives.Native.tuple3",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.comp",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Tactics.NamedView.open_term_with",
"FStar.Pervasives.Inl",
"FStar.Pervasives.Inr",
"FStar.Tactics.NamedView.open_comp_with",
"FStar.Stubs.Reflection.V2.Data.comp_view",
"Prims.precedes",
"FStar.Stubs.Reflection.V2.Builtins.inspect_comp",
"FStar.Tactics.NamedView.open_binder"
] | [] | false | true | false | false | false | let open_match_returns_ascription (mra: R.match_returns_ascription) : Tac match_returns_ascription =
| let b, (ct, topt, use_eq) = mra in
let nb = open_binder b in
let ct =
match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq)) | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.close_view | val close_view (tv: named_term_view) : Tot term_view | val close_view (tv: named_term_view) : Tot term_view | let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 507,
"start_col": 0,
"start_line": 457
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | tv: FStar.Tactics.NamedView.named_term_view -> FStar.Stubs.Reflection.V2.Data.term_view | Prims.Tot | [
"total"
] | [] | [
"FStar.Tactics.NamedView.named_term_view",
"FStar.Tactics.NamedView.namedv",
"FStar.Stubs.Reflection.V2.Data.Tv_Var",
"FStar.Stubs.Reflection.V2.Builtins.pack_namedv",
"FStar.Tactics.NamedView.bv",
"FStar.Stubs.Reflection.V2.Data.Tv_BVar",
"FStar.Stubs.Reflection.V2.Builtins.pack_bv",
"FStar.Stubs.Reflection.Types.fv",
"FStar.Stubs.Reflection.V2.Data.Tv_FVar",
"FStar.Stubs.Reflection.V2.Data.universes",
"FStar.Stubs.Reflection.V2.Data.Tv_UInst",
"FStar.Tactics.NamedView.term",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Stubs.Reflection.V2.Data.Tv_App",
"FStar.Tactics.NamedView.universe",
"FStar.Stubs.Reflection.V2.Data.Tv_Type",
"FStar.Stubs.Reflection.V2.Data.vconst",
"FStar.Stubs.Reflection.V2.Data.Tv_Const",
"Prims.nat",
"FStar.Stubs.Reflection.Types.ctx_uvar_and_subst",
"FStar.Stubs.Reflection.V2.Data.Tv_Uvar",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Stubs.Reflection.V2.Data.Tv_AscribedT",
"FStar.Tactics.NamedView.comp",
"FStar.Stubs.Reflection.V2.Data.Tv_AscribedC",
"FStar.Stubs.Reflection.V2.Builtins.pack_comp",
"FStar.Stubs.Reflection.V2.Data.Tv_Unknown",
"FStar.Stubs.Reflection.V2.Data.Tv_Unsupp",
"FStar.Tactics.NamedView.binder",
"FStar.Stubs.Reflection.Types.binder",
"FStar.Stubs.Reflection.V2.Data.Tv_Abs",
"FStar.Stubs.Reflection.V2.Data.term_view",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.close_term",
"FStar.Stubs.Reflection.V2.Data.Tv_Arrow",
"FStar.Stubs.Reflection.Types.comp",
"FStar.Tactics.NamedView.close_comp",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Stubs.Reflection.V2.Data.simple_binder",
"FStar.Stubs.Reflection.V2.Data.Tv_Refine",
"FStar.Tactics.NamedView.close_term_simple",
"Prims.list",
"FStar.Stubs.Reflection.V2.Data.Tv_Let",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NM",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"Prims.Nil",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.NamedView.branch",
"FStar.Stubs.Reflection.V2.Data.Tv_Match",
"FStar.Stubs.Reflection.Types.match_returns_ascription",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"FStar.Tactics.NamedView.close_match_returns_ascription",
"FStar.Stubs.Reflection.V2.Data.branch",
"FStar.List.Tot.Base.map",
"FStar.Tactics.NamedView.close_branch"
] | [] | false | false | false | true | false | let close_view (tv: named_term_view) : Tot term_view =
| match tv with
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def = if recf then subst_term [NM (r_binder_to_namedv nb) 0] def else def in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.comp_to_string | val comp_to_string (c:comp) : Tac string | val comp_to_string (c:comp) : Tac string | let comp_to_string (c:comp) : Tac string = Stubs.Tactics.V2.Builtins.comp_to_string (R.pack_comp c) | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 99,
"end_line": 662,
"start_col": 0,
"start_line": 662
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t')
private
let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ
[@@plugin]
let inspect_sigelt (s : sigelt) : Tac named_sigelt_view =
let sv = R.inspect_sigelt s in
(* dump ("sv orig = " ^ term_to_string (quote sv)); *)
open_sigelt_view sv
[@@plugin]
let pack_sigelt (sv:named_sigelt_view{~(Unk? sv)}) : Tac sigelt =
let sv = close_sigelt_view sv in
R.pack_sigelt sv
let tcc (e:env) (t:term) : Tac comp =
let c : R.comp = Stubs.Tactics.V2.Builtins.tcc e t in
R.inspect_comp c | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: FStar.Tactics.NamedView.comp -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.NamedView.comp",
"FStar.Stubs.Tactics.V2.Builtins.comp_to_string",
"FStar.Stubs.Reflection.V2.Builtins.pack_comp",
"Prims.string"
] | [] | false | true | false | false | false | let comp_to_string (c: comp) : Tac string =
| Stubs.Tactics.V2.Builtins.comp_to_string (R.pack_comp c) | false |
FStar.Tactics.Arith.fst | FStar.Tactics.Arith.is_arith_goal | val is_arith_goal: Prims.unit -> Tac bool | val is_arith_goal: Prims.unit -> Tac bool | let is_arith_goal () : Tac bool =
let g = cur_goal () in
match run_tm (is_arith_prop g) with
| Inr _ -> true
| _ -> false | {
"file_name": "ulib/FStar.Tactics.Arith.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 27,
"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.Tactics.Arith
open FStar.Tactics.V2
open FStar.Reflection.V2.Formula
open FStar.Reflection.V2.Arith | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.Formula.fst.checked",
"FStar.Reflection.V2.Arith.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.Arith.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Formula",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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.bool | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Reflection.V2.Arith.prop",
"FStar.Pervasives.either",
"Prims.string",
"Prims.bool",
"FStar.Reflection.V2.Arith.run_tm",
"FStar.Reflection.V2.Arith.is_arith_prop",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.V2.Derived.cur_goal"
] | [] | false | true | false | false | false | let is_arith_goal () : Tac bool =
| let g = cur_goal () in
match run_tm (is_arith_prop g) with
| Inr _ -> true
| _ -> false | false |
FStar.Tactics.Arith.fst | FStar.Tactics.Arith.split_arith | val split_arith : unit -> Tac unit | val split_arith : unit -> Tac unit | let rec split_arith () =
if is_arith_goal () then
begin
prune "";
addns "Prims";
smt ()
end
else begin
let g = cur_goal () in
match term_as_formula g with
| True_ ->
trivial ()
| And l r ->
seq FStar.Tactics.split split_arith
| Implies p q ->
let _ = implies_intro () in
seq split_arith l_revert
| Forall _x _sort _p ->
let bs = forall_intros () in
seq split_arith (fun () -> l_revert_all bs)
| _ ->
()
end | {
"file_name": "ulib/FStar.Tactics.Arith.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 52,
"start_col": 0,
"start_line": 30
} | (*
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.Arith
open FStar.Tactics.V2
open FStar.Reflection.V2.Formula
open FStar.Reflection.V2.Arith
// decide if the current goal is arith, drop the built representation of it
let is_arith_goal () : Tac bool =
let g = cur_goal () in
match run_tm (is_arith_prop g) with
| Inr _ -> true
| _ -> false | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Reflection.V2.Formula.fst.checked",
"FStar.Reflection.V2.Arith.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.Arith.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Arith",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2.Formula",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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.Stubs.Tactics.V2.Builtins.addns",
"FStar.Stubs.Tactics.V2.Builtins.prune",
"Prims.bool",
"FStar.Tactics.V2.Derived.trivial",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.V2.Derived.seq",
"FStar.Tactics.V1.Logic.split",
"FStar.Tactics.Arith.split_arith",
"FStar.Tactics.V2.Logic.l_revert",
"FStar.Tactics.NamedView.binding",
"FStar.Tactics.V2.Logic.implies_intro",
"FStar.Tactics.NamedView.bv",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.V2.Logic.l_revert_all",
"Prims.list",
"FStar.Tactics.V2.Logic.forall_intros",
"FStar.Reflection.V2.Formula.formula",
"FStar.Reflection.V2.Formula.term_as_formula",
"FStar.Tactics.V2.Derived.cur_goal",
"FStar.Tactics.Arith.is_arith_goal"
] | [
"recursion"
] | false | true | false | false | false | let rec split_arith () =
| if is_arith_goal ()
then
(prune "";
addns "Prims";
smt ())
else
let g = cur_goal () in
match term_as_formula g with
| True_ -> trivial ()
| And l r -> seq FStar.Tactics.split split_arith
| Implies p q ->
let _ = implies_intro () in
seq split_arith l_revert
| Forall _x _sort _p ->
let bs = forall_intros () in
seq split_arith (fun () -> l_revert_all bs)
| _ -> () | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.open_view | val open_view (tv: term_view) : Tac named_term_view | val open_view (tv: term_view) : Tac named_term_view | let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 454,
"start_col": 0,
"start_line": 411
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | tv: FStar.Stubs.Reflection.V2.Data.term_view
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_term_view | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.V2.Data.term_view",
"FStar.Stubs.Reflection.Types.namedv",
"FStar.Tactics.NamedView.Tv_Var",
"FStar.Stubs.Reflection.V2.Builtins.inspect_namedv",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Stubs.Reflection.Types.bv",
"FStar.Tactics.NamedView.Tv_BVar",
"FStar.Stubs.Reflection.V2.Builtins.inspect_bv",
"FStar.Stubs.Reflection.Types.fv",
"FStar.Tactics.NamedView.Tv_FVar",
"FStar.Stubs.Reflection.V2.Data.universes",
"FStar.Tactics.NamedView.Tv_UInst",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Tactics.NamedView.Tv_App",
"FStar.Stubs.Reflection.Types.universe",
"FStar.Tactics.NamedView.Tv_Type",
"FStar.Stubs.Reflection.V2.Data.vconst",
"FStar.Tactics.NamedView.Tv_Const",
"Prims.nat",
"FStar.Stubs.Reflection.Types.ctx_uvar_and_subst",
"FStar.Tactics.NamedView.Tv_Uvar",
"FStar.Pervasives.Native.option",
"Prims.bool",
"FStar.Tactics.NamedView.Tv_AscribedT",
"FStar.Stubs.Reflection.Types.comp",
"FStar.Tactics.NamedView.Tv_AscribedC",
"FStar.Stubs.Reflection.V2.Builtins.inspect_comp",
"FStar.Tactics.NamedView.Tv_Unknown",
"FStar.Tactics.NamedView.Tv_Unsupp",
"FStar.Stubs.Reflection.Types.binder",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.Tv_Abs",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.NamedView.open_term",
"FStar.Tactics.NamedView.comp",
"FStar.Tactics.NamedView.Tv_Arrow",
"FStar.Tactics.NamedView.open_comp",
"FStar.Stubs.Reflection.V2.Data.simple_binder",
"FStar.Tactics.NamedView.simple_binder",
"FStar.Tactics.NamedView.Tv_Refine",
"FStar.Tactics.NamedView.open_term_simple",
"Prims.list",
"FStar.Tactics.NamedView.Tv_Let",
"FStar.Stubs.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.DB",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"Prims.Nil",
"FStar.Stubs.Reflection.Types.match_returns_ascription",
"FStar.Stubs.Reflection.V2.Data.branch",
"FStar.Tactics.NamedView.Tv_Match",
"FStar.Tactics.NamedView.match_returns_ascription",
"FStar.Tactics.Util.map_opt",
"FStar.Tactics.NamedView.open_match_returns_ascription",
"FStar.Tactics.NamedView.branch",
"FStar.Tactics.Util.map",
"FStar.Tactics.NamedView.open_branch"
] | [] | false | true | false | false | false | let open_view (tv: term_view) : Tac named_term_view =
| match tv with
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def = if recf then subst_term [DB 0 (r_binder_to_namedv nb)] def else def in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.open_n_binders_from_arrow | val open_n_binders_from_arrow (bs: binders) (t: term) : Tac term | val open_n_binders_from_arrow (bs: binders) (t: term) : Tac term | let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 562,
"start_col": 0,
"start_line": 554
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | bs: FStar.Tactics.NamedView.binders -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.NamedView.binders",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.binder",
"Prims.list",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.NamedView.open_n_binders_from_arrow",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Builtins.subst_term",
"Prims.Cons",
"FStar.Stubs.Syntax.Syntax.subst_elt",
"FStar.Stubs.Syntax.Syntax.NT",
"FStar.Tactics.NamedView.r_binder_to_namedv",
"FStar.Tactics.NamedView.pack",
"FStar.Tactics.NamedView.Tv_Var",
"FStar.Stubs.Reflection.V2.Builtins.inspect_namedv",
"Prims.Nil",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Tactics.Effect.raise",
"FStar.Tactics.NamedView.NotEnoughBinders",
"FStar.Tactics.NamedView.inspect"
] | [
"recursion"
] | false | true | false | false | false | let rec open_n_binders_from_arrow (bs: binders) (t: term) : Tac term =
| match bs with
| [] -> t
| b :: bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' =
subst_term [
NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))
]
t'
in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.open_sigelt_view | val open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view | val open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view | let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 603,
"start_col": 0,
"start_line": 565
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | sv: FStar.Stubs.Reflection.V2.Data.sigelt_view
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.named_sigelt_view | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Stubs.Reflection.V2.Data.sigelt_view",
"Prims.bool",
"Prims.list",
"FStar.Stubs.Reflection.Types.letbinding",
"FStar.Tactics.NamedView.Sg_Let",
"FStar.Tactics.NamedView.Mknamed_sigelt_view__Sg_Let__payload",
"FStar.Tactics.NamedView.named_sigelt_view",
"FStar.Tactics.NamedView.letbinding",
"FStar.Tactics.Util.map",
"FStar.Tactics.NamedView.open_lb",
"FStar.Stubs.Reflection.Types.name",
"FStar.Stubs.Reflection.Types.univ_name",
"FStar.Stubs.Reflection.Types.binders",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Stubs.Reflection.V2.Data.ctor",
"FStar.Tactics.NamedView.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.Sg_Inductive",
"FStar.Tactics.NamedView.Mknamed_sigelt_view__Sg_Inductive__payload",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Tactics.NamedView.open_n_binders_from_arrow",
"FStar.Tactics.NamedView.open_term_n",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Stubs.Reflection.Types.binder",
"FStar.Tactics.NamedView.subst_r_binders",
"FStar.Tactics.NamedView.open_univ_s",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Tactics.NamedView.Sg_Val",
"FStar.Tactics.NamedView.Mknamed_sigelt_view__Sg_Val__payload",
"FStar.Tactics.NamedView.Unk"
] | [] | false | true | false | false | false | let open_sigelt_view (sv: sigelt_view) : Tac named_sigelt_view =
| match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
Sg_Let ({ isrec = isrec; lbs = lbs })
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
let params, typ = open_term_n params typ in
let ctors =
map (fun (nm, ty) ->
let ty' = open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive ({ nm = nm; univs = univs; params = params; typ = typ; ctors = ctors })
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val ({ nm = nm; univs = univs; typ = typ })
| RD.Unk -> Unk | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.proposition_to_printout | val proposition_to_printout (ge: genv) (prefix: string) (p: proposition) : Tac string | val proposition_to_printout (ge: genv) (prefix: string) (p: proposition) : Tac string | let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 100,
"start_col": 0,
"start_line": 99
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix "" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ge: FStar.InteractiveHelpers.Base.genv ->
prefix: Prims.string ->
p: FStar.InteractiveHelpers.Propositions.proposition
-> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.InteractiveHelpers.Propositions.proposition",
"FStar.InteractiveHelpers.Output.term_to_printout"
] | [] | false | true | false | false | false | let proposition_to_printout (ge: genv) (prefix: string) (p: proposition) : Tac string =
| term_to_printout ge prefix p | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.term_to_printout | val term_to_printout (ge: genv) (prefix: string) (t: term) : Tac string | val term_to_printout (ge: genv) (prefix: string) (t: term) : Tac string | let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t) | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 92,
"start_col": 0,
"start_line": 85
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ge: FStar.InteractiveHelpers.Base.genv ->
prefix: Prims.string ->
t: FStar.Stubs.Reflection.Types.term
-> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Stubs.Reflection.Types.term",
"FStar.InteractiveHelpers.Output.string_to_printout",
"FStar.Stubs.Tactics.V1.Builtins.term_to_string",
"FStar.Reflection.V1.Derived.mk_e_app",
"FStar.Tactics.V1.Derived.mk_abs",
"Prims.list",
"FStar.Tactics.Util.map",
"FStar.Pervasives.Native.tuple2",
"FStar.Stubs.Reflection.Types.bv",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Stubs.Tactics.V1.Builtins.pack",
"FStar.Stubs.Reflection.V1.Data.Tv_Var",
"FStar.Stubs.Reflection.Types.binder",
"FStar.List.Tot.Base.map",
"FStar.Reflection.V1.Derived.mk_binder",
"FStar.InteractiveHelpers.ExploreTerm.abs_free_in"
] | [] | false | true | false | false | false | let term_to_printout (ge: genv) (prefix: string) (t: term) : Tac string =
| let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t) | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.mk_arr | val mk_arr (args: list binder) (t: term) : Tac term | val mk_arr (args: list binder) (t: term) : Tac term | let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t') | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 611,
"start_col": 0,
"start_line": 606
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | args: Prims.list FStar.Tactics.NamedView.binder -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.term | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.list",
"FStar.Tactics.NamedView.binder",
"FStar.Tactics.NamedView.term",
"FStar.Tactics.NamedView.pack",
"FStar.Tactics.NamedView.Tv_Arrow",
"FStar.Stubs.Reflection.V2.Data.comp_view",
"FStar.Stubs.Reflection.V2.Data.C_Total",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.NamedView.mk_arr"
] | [
"recursion"
] | false | true | false | false | false | let rec mk_arr (args: list binder) (t: term) : Tac term =
| match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t') | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.string_to_printout | val string_to_printout (prefix data: string) : Tot string | val string_to_printout (prefix data: string) : Tot string | let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n" | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 83,
"start_col": 0,
"start_line": 82
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example). | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | prefix: Prims.string -> data: Prims.string -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.op_Hat"
] | [] | false | false | false | true | false | let string_to_printout (prefix data: string) : Tot string =
| prefix ^ ":\n" ^ data ^ "\n" | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.printout_result | val printout_result (prefix: string) (res: export_result) : Tac unit | val printout_result (prefix: string) (res: export_result) : Tac unit | let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res) | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 39,
"end_line": 146,
"start_col": 0,
"start_line": 144
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | prefix: Prims.string -> res: FStar.InteractiveHelpers.Output.export_result
-> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.string",
"FStar.InteractiveHelpers.Output.export_result",
"FStar.Stubs.Tactics.V1.Builtins.print",
"Prims.unit",
"FStar.InteractiveHelpers.Output.result_to_printout"
] | [] | false | true | false | false | false | let printout_result (prefix: string) (res: export_result) : Tac unit =
| print (result_to_printout prefix res) | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.propositions_to_printout | val propositions_to_printout (ge: genv) (prefix: string) (pl: list proposition) : Tac string | val propositions_to_printout (ge: genv) (prefix: string) (pl: list proposition) : Tac string | let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 113,
"start_col": 0,
"start_line": 102
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ge: FStar.InteractiveHelpers.Base.genv ->
prefix: Prims.string ->
pl: Prims.list FStar.InteractiveHelpers.Propositions.proposition
-> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"Prims.list",
"FStar.InteractiveHelpers.Propositions.proposition",
"Prims.int",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.Util.fold_left",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Addition",
"Prims.op_Hat",
"FStar.InteractiveHelpers.Output.string_to_printout",
"Prims.string_of_int",
"FStar.List.Tot.Base.length",
"FStar.InteractiveHelpers.Output.proposition_to_printout"
] | [] | false | true | false | false | false | let propositions_to_printout (ge: genv) (prefix: string) (pl: list proposition) : Tac string =
| let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i + 1
in
let str, _ = fold_left concat_prop (str, 0) pl in
str | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.error_message_to_printout | val error_message_to_printout (prefix: string) (message: option string) : Tot string | val error_message_to_printout (prefix: string) (message: option string) : Tot string | let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 117,
"start_col": 0,
"start_line": 115
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | prefix: Prims.string -> message: FStar.Pervasives.Native.option Prims.string -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.InteractiveHelpers.Output.string_to_printout",
"Prims.op_Hat"
] | [] | false | false | false | true | false | let error_message_to_printout (prefix: string) (message: option string) : Tot string =
| let msg =
match message with
| Some msg -> msg
| _ -> ""
in
string_to_printout (prefix ^ ":error") msg | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.printout_failure | val printout_failure (err: string) : Tac unit | val printout_failure (err: string) : Tac unit | let printout_failure (err : string) : Tac unit =
printout_result "ainfo" (EFailure err) | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 154,
"start_col": 0,
"start_line": 153
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res)
/// The function to use to export the results in case of success
let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | err: Prims.string -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.string",
"FStar.InteractiveHelpers.Output.printout_result",
"FStar.InteractiveHelpers.Output.EFailure",
"Prims.unit"
] | [] | false | true | false | false | false | let printout_failure (err: string) : Tac unit =
| printout_result "ainfo" (EFailure err) | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.printout_success | val printout_success (ge: genv) (a: assertions) : Tac unit | val printout_success (ge: genv) (a: assertions) : Tac unit | let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a) | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 150,
"start_col": 0,
"start_line": 149
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ge: FStar.InteractiveHelpers.Base.genv -> a: FStar.InteractiveHelpers.Propositions.assertions
-> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.InteractiveHelpers.Base.genv",
"FStar.InteractiveHelpers.Propositions.assertions",
"FStar.InteractiveHelpers.Output.printout_result",
"FStar.InteractiveHelpers.Output.ESuccess",
"Prims.unit"
] | [] | false | true | false | false | false | let printout_success (ge: genv) (a: assertions) : Tac unit =
| printout_result "ainfo" (ESuccess ge a) | false |
FStar.Tactics.NamedView.fst | FStar.Tactics.NamedView.close_sigelt_view | val close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)}) | val close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)}) | let close_sigelt_view (sv : named_sigelt_view{~(Unk? sv)}) : Tac (sv:sigelt_view{~(RD.Unk? sv)}) =
match sv with
| Sg_Let { isrec; lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive {nm; univs; params; typ; ctors} ->
let nparams = List.Tot.length params in
(* Abstract constructors by the parameters. This
is the inverse of the open_n_binders_from_arrow above. *)
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
(* Close parameters in themselves and typ *)
let params, typ = close_term_n params typ in
(* close univs *)
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val {nm; univs; typ} ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ | {
"file_name": "ulib/FStar.Tactics.NamedView.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 645,
"start_col": 0,
"start_line": 614
} | (*
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.NamedView
(* inner let bindings not encoded, OK *)
#set-options "--warn_error -242"
(* This file is part of the tactics core, we open only what's needed. *)
open FStar.Tactics.Effect
open FStar.Tactics.Util
open FStar.Stubs.Tactics.V2.Builtins
exception LengthMismatch
exception NotEnoughBinders
(* We work with reflection V2. *)
module R = FStar.Reflection.V2
module RD = FStar.Stubs.Reflection.V2.Data
let open_universe_view (v:RD.universe_view) : named_universe_view =
match v with
| R.Uv_Zero -> Uv_Zero
| R.Uv_Succ u -> Uv_Succ u
| R.Uv_Max us -> Uv_Max us
| R.Uv_BVar n -> Uv_BVar n
| R.Uv_Name i -> Uv_Name (inspect_ident i)
| R.Uv_Unif uvar -> Uv_Unif uvar
| R.Uv_Unk -> Uv_Unk
let inspect_universe (u:universe) : named_universe_view =
let v = R.inspect_universe u in
open_universe_view v
let close_universe_view (v:named_universe_view) : R.universe_view =
match v with
| Uv_Zero -> R.Uv_Zero
| Uv_Succ u -> R.Uv_Succ u
| Uv_Max us -> R.Uv_Max us
| Uv_BVar n -> R.Uv_BVar n
| Uv_Name i -> R.Uv_Name (pack_ident i)
| Uv_Unif uvar -> R.Uv_Unif uvar
| Uv_Unk -> R.Uv_Unk
let pack_universe (uv:named_universe_view) : universe =
let uv = close_universe_view uv in
R.pack_universe uv
private
let __binding_to_binder (bnd : binding) (b : R.binder) : binder =
{
ppname = bnd.ppname;
uniq = bnd.uniq;
sort = bnd.sort;
qual = (inspect_binder b).qual;
attrs = (inspect_binder b).attrs;
}
private
let r_binder_to_namedv (b : binder) : R.namedv =
pack_namedv {
uniq = b.uniq;
sort = seal b.sort;
ppname = b.ppname;
}
private
let open_binder (b : R.binder) : Tac binder =
let n = fresh () in
let bv = inspect_binder b in
{
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
private
let close_binder (b : binder) : R.binder =
pack_binder {
sort = b.sort;
qual = b.qual;
ppname = b.ppname;
attrs = b.attrs;
}
private
let open_term_with (b : R.binder) (nb : binder) (t : term) : Tac term =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
t'
private
let open_term (b : R.binder) (t : term) : Tac (binder & term) =
let bndr : binder = open_binder b in
(bndr, open_term_with b bndr t)
let subst_comp (s : subst_t) (c : comp) : comp =
inspect_comp (R.subst_comp s (pack_comp c))
private
let open_comp (b : R.binder) (t : comp) : Tac (binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_with (b : R.binder) (nb : binder) (c : comp) : Tac comp =
let nv : R.namedv = pack_namedv {
uniq = nb.uniq;
sort = seal nb.sort;
ppname = nb.ppname;
}
in
let t' = subst_comp [DB 0 nv] c in
t'
(* FIXME: unfortunate duplication here. The effect means this proof cannot
be done extrinsically. Can we add a refinement to the binder? *)
private
let open_term_simple (b : R.simple_binder) (t : term) : Tac (simple_binder & term) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_term [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
private
let open_comp_simple (b : R.simple_binder) (t : comp) : Tac (simple_binder & comp) =
let n = fresh () in
let bv : binder_view = inspect_binder b in
let nv : R.namedv = pack_namedv {
uniq = n;
sort = seal bv.sort;
ppname = bv.ppname;
}
in
let t' = subst_comp [DB 0 nv] t in
let bndr : binder = {
uniq = n;
sort = bv.sort;
ppname = bv.ppname;
qual = bv.qual;
attrs = bv.attrs;
}
in
(bndr, t')
(* This can be useful externally *)
let close_term (b:binder) (t:term) : R.binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_comp (b:binder) (t:comp) : R.binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let b = pack_binder { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
(b, t')
private
let close_term_simple (b:simple_binder) (t:term) : R.simple_binder & term =
let nv = r_binder_to_namedv b in
let t' = subst_term [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let close_comp_simple (b:simple_binder) (t:comp) : R.simple_binder & comp =
let nv = r_binder_to_namedv b in
let t' = subst_comp [NM nv 0] t in
let bv : binder_view = { sort = b.sort; ppname = b.ppname; qual = b.qual; attrs = b.attrs } in
let b = pack_binder bv in
inspect_pack_binder bv;
(b, t')
private
let r_subst_binder_sort (s : subst_t) (b : R.binder) : R.binder =
let v = inspect_binder b in
let v = { v with sort = subst_term s v.sort } in
pack_binder v
let subst_binder_sort (s : subst_t) (b : binder) : binder =
{ b with sort = subst_term s b.sort }
(* Can't define this inside open_term_n. See #2955 *)
private
let rec __open_term_n_aux (bs : list R.binder) (nbs : list binder) (s : subst_t) : Tac (list binder & subst_t) =
match bs with
| [] -> nbs, s
| b::bs ->
let b = r_subst_binder_sort s b in
let b = open_binder b in
let nv = r_binder_to_namedv b in
__open_term_n_aux bs (b::nbs) (DB 0 nv :: shift_subst 1 s)
private
let open_term_n (bs : list R.binder) (t : term) : Tac (list binder & term) =
let nbs, s = __open_term_n_aux bs [] [] in
List.Tot.rev nbs, subst_term s t
private
let rec open_term_n_with (bs : list R.binder) (nbs : list binder) (t : term) : Tac term =
match bs, nbs with
| [], [] -> t
| b::bs, nb::nbs ->
let t' = open_term_n_with bs nbs t in
let t'' = open_term_with b nb t' in
t''
| _ -> raise LengthMismatch
private
let close_term_n (bs : list binder) (t : term) : list R.binder & term =
let rec aux (bs : list binder) (cbs : list R.binder) (s : subst_t) : list R.binder & subst_t =
match bs with
| [] -> cbs, s
| b::bs ->
let b = subst_binder_sort s b in
let nv = r_binder_to_namedv b in
let b = close_binder b in
aux bs (b::cbs) (NM nv 0 :: shift_subst 1 s)
in
let cbs, s = aux bs [] [] in
List.Tot.rev cbs, subst_term s t
private
let rec open_term_n_simple (bs : list R.simple_binder) (t : term) : Tac (list simple_binder & term) =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = open_term_n_simple bs t in
let b', t'' = open_term_simple b t' in
(b'::bs', t'')
private
let rec close_term_n_simple (bs : list simple_binder) (t : term) : list R.simple_binder & term =
match bs with
| [] -> ([], t)
| b::bs ->
let bs', t' = close_term_n_simple bs t in
let b', t'' = close_term_simple b t' in
(b'::bs', t'')
private
let rec open_pat (p : R.pattern) (s : subst_t) : Tac (pattern & subst_t) =
match p with
| R.Pat_Constant c ->
Pat_Constant {c=c}, s
| R.Pat_Var ssort n ->
let sort = unseal ssort in
let sort = subst_term s sort in
let nvv : namedv = {
uniq = fresh();
sort = seal sort;
ppname = n;
}
in
let nv = pack_namedv nvv in
Pat_Var {v=nvv; sort=seal sort}, (DB 0 nv) :: shift_subst 1 s
| R.Pat_Cons head univs subpats ->
let subpats, s = fold_left (fun (pats,s) (pat,b) ->
let pat, s' = open_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
Pat_Cons {head=head; univs=univs; subpats=subpats}, s
| R.Pat_Dot_Term None ->
Pat_Dot_Term {t=None}, s
| R.Pat_Dot_Term (Some t) ->
let t = subst_term s t in
Pat_Dot_Term {t=Some t}, s
private
let open_branch (b : R.branch) : Tac branch =
let (pat, t) = b in
let pat, s = open_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let rec close_pat (p : pattern) (s : subst_t) : Tot (R.pattern & subst_t) =
match p with
| Pat_Constant {c} ->
R.Pat_Constant c, s
| Pat_Var {v; sort} ->
let nv = pack_namedv v in
(* NOTE: we cannot do anything on the sort wihtout going
into TAC. Need a sealed_bind. *)
//let sort = unseal sort in
//let sort = subst_term s sort in
//let sort = seal sort in
let s = (NM nv 0) :: shift_subst 1 s in
R.Pat_Var sort v.ppname, s
| Pat_Cons {head; univs; subpats} ->
let subpats, s = List.Tot.fold_left (fun (pats,s) (pat,b) ->
assume(pat << p);
let pat, s' = close_pat pat s in
((pat,b)::pats, s'))
([], s) subpats
in
let subpats = List.Tot.rev subpats in
R.Pat_Cons head univs subpats, s
| Pat_Dot_Term {t=None} ->
R.Pat_Dot_Term None, s
| Pat_Dot_Term {t=Some t} ->
let t = subst_term s t in
R.Pat_Dot_Term (Some t), s
private
let close_branch (b : branch) : Tot R.branch =
let (pat, t) = b in
let pat, s = close_pat pat [] in
let t' = subst_term s t in
(pat, t')
private
let open_match_returns_ascription (mra : R.match_returns_ascription) : Tac match_returns_ascription =
let (b, (ct, topt, use_eq)) = mra in
let nb = open_binder b in
let ct = match ct with
| Inl t -> Inl (open_term_with b nb t)
| Inr c ->
let c = inspect_comp c in
let c = open_comp_with b nb c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (open_term_with b nb t)
in
(nb, (ct, topt, use_eq))
private
let close_match_returns_ascription (mra : match_returns_ascription) : R.match_returns_ascription =
let (nb, (ct, topt, use_eq)) = mra in
let b = close_binder nb in
// FIXME: all this is repeating the close_binder work, for no good reason
let ct = match ct with
| Inl t -> Inl (snd (close_term nb t))
| Inr c ->
let _, c = close_comp nb c in
let c = pack_comp c in
Inr c
in
let topt =
match topt with
| None -> None
| Some t -> Some (snd (close_term nb t))
in
(b, (ct, topt, use_eq))
private
let open_view (tv:term_view) : Tac named_term_view =
match tv with
(* Nothing interesting *)
| RD.Tv_Var v -> Tv_Var (inspect_namedv v)
| RD.Tv_BVar v -> Tv_BVar (inspect_bv v)
| RD.Tv_FVar v -> Tv_FVar v
| RD.Tv_UInst v us -> Tv_UInst v us
| RD.Tv_App hd a -> Tv_App hd a
| RD.Tv_Type u -> Tv_Type u
| RD.Tv_Const c -> Tv_Const c
| RD.Tv_Uvar n ctx_uvar_and_subst -> Tv_Uvar n ctx_uvar_and_subst
| RD.Tv_AscribedT e t tac use_eq -> Tv_AscribedT e t tac use_eq
| RD.Tv_AscribedC e c tac use_eq -> Tv_AscribedC e (inspect_comp c) tac use_eq
| RD.Tv_Unknown -> Tv_Unknown
| RD.Tv_Unsupp -> Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| RD.Tv_Abs b body ->
let nb, body = open_term b body in
Tv_Abs nb body
| RD.Tv_Arrow b c ->
let nb, c = open_comp b (inspect_comp c) in
Tv_Arrow nb c
| RD.Tv_Refine b ref ->
let nb, ref = open_term_simple b ref in
Tv_Refine nb ref
| RD.Tv_Let recf attrs b def body ->
let nb, body = open_term_simple b body in
let def =
if recf
then subst_term [DB 0 (r_binder_to_namedv nb)] def
else def
in
Tv_Let recf attrs nb def body
| RD.Tv_Match scrutinee ret brs ->
let brs = map open_branch brs in
let ret = map_opt open_match_returns_ascription ret in
Tv_Match scrutinee ret brs
private
let close_view (tv : named_term_view) : Tot term_view =
match tv with
(* Nothing interesting *)
| Tv_Var v -> RD.Tv_Var (pack_namedv v)
| Tv_BVar v -> RD.Tv_BVar (pack_bv v)
| Tv_FVar v -> RD.Tv_FVar v
| Tv_UInst v us -> RD.Tv_UInst v us
| Tv_App hd a -> RD.Tv_App hd a
| Tv_Type u -> RD.Tv_Type u
| Tv_Const c -> RD.Tv_Const c
| Tv_Uvar n ctx_uvar_and_subst -> RD.Tv_Uvar n ctx_uvar_and_subst
| Tv_AscribedT e t tac use_eq -> RD.Tv_AscribedT e t tac use_eq
| Tv_AscribedC e c tac use_eq -> RD.Tv_AscribedC e (pack_comp c) tac use_eq
| Tv_Unknown -> RD.Tv_Unknown
| Tv_Unsupp -> RD.Tv_Unsupp
(* Below are the nodes that actually involve a binder.
Open them and convert to named binders. *)
| Tv_Abs nb body ->
let b, body = close_term nb body in
RD.Tv_Abs b body
| Tv_Arrow nb c ->
let b, c = close_comp nb c in
let c = pack_comp c in
RD.Tv_Arrow b c
| Tv_Refine nb ref ->
let b, ref = close_term_simple nb ref in
RD.Tv_Refine b ref
| Tv_Let recf attrs nb def body ->
let def =
if recf
then subst_term [NM (r_binder_to_namedv nb) 0] def
else def
in
let b, body = close_term_simple nb body in
RD.Tv_Let recf attrs b def body
| Tv_Match scrutinee ret brs ->
let brs = List.Tot.map close_branch brs in
(* NOTE: this used to use FStar.Option.mapTot, but that brings
in way too many dependencies. *)
let ret =
match ret with
| None -> None
| Some asc -> Some (close_match_returns_ascription asc)
in
RD.Tv_Match scrutinee ret brs
[@@plugin; coercion]
let inspect (t:term) : Tac named_term_view =
let t = compress t in
let tv = inspect_ln t in
open_view tv
[@@plugin; coercion]
let pack (tv:named_term_view) : Tot term =
let tv = close_view tv in
pack_ln tv
private
let open_univ_s (us : list R.univ_name) : Tac (list univ_name & subst_t) =
let n = List.Tot.length us in
let s = mapi (fun i u -> UN (n-1-i) (R.pack_universe (R.Uv_Name u))) us in
Util.map (fun i -> inspect_ident i) us, s
private
let close_univ_s (us : list univ_name) : list R.univ_name & subst_t =
let n = List.Tot.length us in
let us = List.Tot.map (fun i -> pack_ident i) us in
let s = List.Tot.mapi (fun i u -> UD u (n-i-1)) us in
us, s
private
let open_lb (lb : R.letbinding) : Tac letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = inspect_lb lb in
let lb_us, s = open_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
{ lb_fv; lb_us; lb_typ; lb_def }
private
let close_lb (lb : letbinding) : R.letbinding =
let {lb_fv; lb_us; lb_typ; lb_def} = lb in
let lb_us, s = close_univ_s lb_us in
let lb_typ = subst_term s lb_typ in
let lb_def = subst_term s lb_def in
pack_lb { lb_fv; lb_us; lb_typ; lb_def }
private
let subst_r_binders (s:subst_t) (bs : list R.binder) : list R.binder =
List.Tot.mapi (fun i b -> r_subst_binder_sort (shift_subst i s) b) bs
private
let rec open_n_binders_from_arrow (bs : binders) (t : term) : Tac term =
match bs with
| [] -> t
| b::bs ->
match inspect t with
| Tv_Arrow b' (C_Total t') ->
let t' = subst_term [NT (r_binder_to_namedv b') (pack (Tv_Var (inspect_namedv (r_binder_to_namedv b))))] t' in
open_n_binders_from_arrow bs t'
| _ -> raise NotEnoughBinders
private
let open_sigelt_view (sv : sigelt_view) : Tac named_sigelt_view =
match sv with
| RD.Sg_Let isrec lbs ->
let lbs = map open_lb lbs in
(* open universes, maybe *)
Sg_Let { isrec; lbs }
| RD.Sg_Inductive nm univs params typ ctors ->
let nparams = List.Tot.length params in
(* Open universes everywhere *)
let univs, s = open_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
(* Open parameters in themselves and in type *)
let params, typ = open_term_n params typ in
(* Remove the parameter binders from the constructors,
replace them by the opened param binders. Hence we get
Cons : a0 -> list a0
instead of
Cons : #a:Type -> a -> list a
for the returned open parameter a0. *)
let ctors =
map (fun (nm, ty) ->
let ty'= open_n_binders_from_arrow params ty in
nm, ty')
ctors
in
Sg_Inductive {nm; univs; params; typ; ctors}
| RD.Sg_Val nm univs typ ->
let univs, s = open_univ_s univs in
let typ = subst_term s typ in
Sg_Val {nm; univs; typ}
| RD.Unk -> Unk
private
let rec mk_arr (args : list binder) (t : term) : Tac term =
match args with
| [] -> t
| a :: args' ->
let t' = C_Total (mk_arr args' t) in
pack (Tv_Arrow a t') | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Util.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Stubs.Tactics.V2.Builtins.fsti.checked",
"FStar.Stubs.Reflection.V2.Data.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Tactics.NamedView.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Stubs.Reflection.V2.Data",
"short_module": "RD"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Tactics.V2.Builtins",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": 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 | sv: FStar.Tactics.NamedView.named_sigelt_view{~(Unk? sv)}
-> FStar.Tactics.Effect.Tac (sv: FStar.Stubs.Reflection.V2.Data.sigelt_view{~(Unk? sv)}) | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.Tactics.NamedView.named_sigelt_view",
"Prims.l_not",
"Prims.b2t",
"FStar.Tactics.NamedView.uu___is_Unk",
"Prims.bool",
"Prims.list",
"FStar.Tactics.NamedView.letbinding",
"FStar.Stubs.Reflection.V2.Data.Sg_Let",
"FStar.Stubs.Reflection.Types.letbinding",
"FStar.List.Tot.Base.map",
"FStar.Tactics.NamedView.close_lb",
"FStar.Stubs.Reflection.V2.Data.sigelt_view",
"FStar.Stubs.Reflection.V2.Data.uu___is_Unk",
"FStar.Stubs.Reflection.Types.name",
"FStar.Tactics.NamedView.univ_name",
"FStar.Tactics.NamedView.binders",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Stubs.Reflection.V2.Data.ctor",
"FStar.Stubs.Reflection.Types.binder",
"FStar.Tactics.NamedView.term",
"FStar.Stubs.Reflection.Types.univ_name",
"FStar.Stubs.Syntax.Syntax.subst_t",
"FStar.Stubs.Reflection.V2.Data.Sg_Inductive",
"FStar.Pervasives.Native.tuple2",
"FStar.Stubs.Reflection.Types.term",
"FStar.Tactics.Util.map",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.V2.Builtins.subst_term",
"FStar.Reflection.V2.Derived.shift_subst",
"FStar.Tactics.NamedView.subst_r_binders",
"FStar.Tactics.NamedView.close_univ_s",
"FStar.Tactics.NamedView.close_term_n",
"FStar.Tactics.NamedView.mk_arr",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Tactics.NamedView.binder",
"FStar.Stubs.Reflection.V2.Data.Sg_Val"
] | [] | false | true | false | false | false | let close_sigelt_view (sv: named_sigelt_view{~(Unk? sv)}) : Tac (sv: sigelt_view{~(RD.Unk? sv)}) =
| match sv with
| Sg_Let { isrec = isrec ; lbs = lbs } ->
let lbs = List.Tot.map close_lb lbs in
RD.Sg_Let isrec lbs
| Sg_Inductive { nm = nm ; univs = univs ; params = params ; typ = typ ; ctors = ctors } ->
let nparams = List.Tot.length params in
let ctors =
map (fun (nm, ty) ->
let ty' = mk_arr params ty in
nm, ty')
ctors
in
let params, typ = close_term_n params typ in
let univs, s = close_univ_s univs in
let params = subst_r_binders s params in
let typ = subst_term (shift_subst nparams s) typ in
let ctors = map (fun (nm, ty) -> nm, subst_term s ty) ctors in
RD.Sg_Inductive nm univs params typ ctors
| Sg_Val { nm = nm ; univs = univs ; typ = typ } ->
let univs, s = close_univ_s univs in
let typ = subst_term s typ in
RD.Sg_Val nm univs typ | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.tadmit_no_warning | val tadmit_no_warning: Prims.unit -> Tac unit | val tadmit_no_warning: Prims.unit -> Tac unit | let tadmit_no_warning () : Tac unit =
apply (`magic_witness) | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 181,
"start_col": 0,
"start_line": 180
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res)
/// The function to use to export the results in case of success
let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a)
/// The function to use to communicate failure in case of error
let printout_failure (err : string) : Tac unit =
printout_result "ainfo" (EFailure err)
let _debug_print_var (name : string) (t : term) : Tac unit =
print ("_debug_print_var: " ^ name ^ ": " ^ term_to_string t);
begin match safe_tc (top_env ()) t with
| Some ty -> print ("type: " ^ term_to_string ty)
| _ -> ()
end;
print ("qualifier: " ^ term_construct t);
begin match inspect t with
| Tv_Var bv ->
let b : bv_view = inspect_bv bv in
print ("Tv_Var: ppname: " ^ name_of_bv bv ^
"; index: " ^ (string_of_int b.bv_index))
| _ -> ()
end;
print "end of _debug_print_var"
/// We use the following to solve goals requiring a unification variable (for
/// which we might not have a candidate, or for which the candidate may not
/// typecheck correctly). We can't use the tactic ``tadmit`` for the simple
/// reason that it generates a warning which may mess up with the subsequent
/// parsing of the data generated by the tactics.
// TODO: actually, there already exists Prims.magic
assume val magic_witness (#a : Type) : a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"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.V1.Derived.apply"
] | [] | false | true | false | false | false | let tadmit_no_warning () : Tac unit =
| apply (`magic_witness) | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output._debug_print_var | val _debug_print_var (name: string) (t: term) : Tac unit | val _debug_print_var (name: string) (t: term) : Tac unit | let _debug_print_var (name : string) (t : term) : Tac unit =
print ("_debug_print_var: " ^ name ^ ": " ^ term_to_string t);
begin match safe_tc (top_env ()) t with
| Some ty -> print ("type: " ^ term_to_string ty)
| _ -> ()
end;
print ("qualifier: " ^ term_construct t);
begin match inspect t with
| Tv_Var bv ->
let b : bv_view = inspect_bv bv in
print ("Tv_Var: ppname: " ^ name_of_bv bv ^
"; index: " ^ (string_of_int b.bv_index))
| _ -> ()
end;
print "end of _debug_print_var" | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 170,
"start_col": 0,
"start_line": 156
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res)
/// The function to use to export the results in case of success
let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a)
/// The function to use to communicate failure in case of error
let printout_failure (err : string) : Tac unit =
printout_result "ainfo" (EFailure err) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | name: Prims.string -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.string",
"FStar.Stubs.Reflection.Types.term",
"FStar.Stubs.Tactics.V1.Builtins.print",
"Prims.unit",
"FStar.Stubs.Reflection.Types.bv",
"Prims.op_Hat",
"Prims.string_of_int",
"FStar.Stubs.Reflection.V1.Data.__proj__Mkbv_view__item__bv_index",
"FStar.Tactics.V1.Derived.name_of_bv",
"FStar.Stubs.Reflection.V1.Data.bv_view",
"FStar.Stubs.Reflection.V1.Builtins.inspect_bv",
"FStar.Stubs.Reflection.V1.Data.term_view",
"FStar.Stubs.Tactics.V1.Builtins.inspect",
"FStar.InteractiveHelpers.Base.term_construct",
"FStar.Stubs.Tactics.V1.Builtins.term_to_string",
"FStar.Pervasives.Native.option",
"FStar.InteractiveHelpers.ExploreTerm.safe_tc",
"FStar.Stubs.Reflection.Types.env",
"FStar.Stubs.Tactics.V1.Builtins.top_env"
] | [] | false | true | false | false | false | let _debug_print_var (name: string) (t: term) : Tac unit =
| print ("_debug_print_var: " ^ name ^ ": " ^ term_to_string t);
(match safe_tc (top_env ()) t with
| Some ty -> print ("type: " ^ term_to_string ty)
| _ -> ());
print ("qualifier: " ^ term_construct t);
(match inspect t with
| Tv_Var bv ->
let b:bv_view = inspect_bv bv in
print ("Tv_Var: ppname: " ^ name_of_bv bv ^ "; index: " ^ (string_of_int b.bv_index))
| _ -> ());
print "end of _debug_print_var" | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.pp_tac | val pp_tac: Prims.unit -> Tac unit | val pp_tac: Prims.unit -> Tac unit | let pp_tac () : Tac unit =
print ("post-processing: " ^ (term_to_string (cur_goal ())));
dump "";
trefl() | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 9,
"end_line": 186,
"start_col": 0,
"start_line": 183
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result
let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%"
let printout_result (prefix:string) (res:export_result) :
Tac unit =
print (result_to_printout prefix res)
/// The function to use to export the results in case of success
let printout_success (ge:genv) (a:assertions) : Tac unit =
printout_result "ainfo" (ESuccess ge a)
/// The function to use to communicate failure in case of error
let printout_failure (err : string) : Tac unit =
printout_result "ainfo" (EFailure err)
let _debug_print_var (name : string) (t : term) : Tac unit =
print ("_debug_print_var: " ^ name ^ ": " ^ term_to_string t);
begin match safe_tc (top_env ()) t with
| Some ty -> print ("type: " ^ term_to_string ty)
| _ -> ()
end;
print ("qualifier: " ^ term_construct t);
begin match inspect t with
| Tv_Var bv ->
let b : bv_view = inspect_bv bv in
print ("Tv_Var: ppname: " ^ name_of_bv bv ^
"; index: " ^ (string_of_int b.bv_index))
| _ -> ()
end;
print "end of _debug_print_var"
/// We use the following to solve goals requiring a unification variable (for
/// which we might not have a candidate, or for which the candidate may not
/// typecheck correctly). We can't use the tactic ``tadmit`` for the simple
/// reason that it generates a warning which may mess up with the subsequent
/// parsing of the data generated by the tactics.
// TODO: actually, there already exists Prims.magic
assume val magic_witness (#a : Type) : a
let tadmit_no_warning () : Tac unit =
apply (`magic_witness) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"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.V1.Derived.trefl",
"FStar.Stubs.Tactics.V1.Builtins.dump",
"FStar.Stubs.Tactics.V1.Builtins.print",
"Prims.string",
"Prims.op_Hat",
"FStar.Stubs.Tactics.V1.Builtins.term_to_string",
"FStar.Stubs.Reflection.Types.term",
"FStar.Tactics.V1.Derived.cur_goal",
"FStar.Stubs.Reflection.Types.typ"
] | [] | false | true | false | false | false | let pp_tac () : Tac unit =
| print ("post-processing: " ^ (term_to_string (cur_goal ())));
dump "";
trefl () | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output._split_subst_at_bv | val _split_subst_at_bv (#a #b: Type) (x: bv) (subst: list ((bv & a) & b))
: Tot (list ((bv & a) & b) & list ((bv & a) & b)) (decreases subst) | val _split_subst_at_bv (#a #b: Type) (x: bv) (subst: list ((bv & a) & b))
: Tot (list ((bv & a) & b) & list ((bv & a) & b)) (decreases subst) | let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2 | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 36,
"start_col": 0,
"start_line": 26
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.Stubs.Reflection.Types.bv -> subst: Prims.list ((FStar.Stubs.Reflection.Types.bv * a) * b)
-> Prims.Tot
(Prims.list ((FStar.Stubs.Reflection.Types.bv * a) * b) *
Prims.list ((FStar.Stubs.Reflection.Types.bv * a) * b)) | Prims.Tot | [
"total",
""
] | [] | [
"FStar.Stubs.Reflection.Types.bv",
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"FStar.InteractiveHelpers.Base.bv_eq",
"Prims.bool",
"Prims.Cons",
"FStar.InteractiveHelpers.Output._split_subst_at_bv"
] | [
"recursion"
] | false | false | false | true | false | let rec _split_subst_at_bv (#a #b: Type) (x: bv) (subst: list ((bv & a) & b))
: Tot (list ((bv & a) & b) & list ((bv & a) & b)) (decreases subst) =
| match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src
then [], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2 | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.subst_shadowed_with_abs_in_assertions | val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions) | val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions) | let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 73,
"start_col": 0,
"start_line": 39
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dbg: Prims.bool ->
ge: FStar.InteractiveHelpers.Base.genv ->
shadowed_bv: FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.bv ->
es: FStar.InteractiveHelpers.Propositions.assertions
-> FStar.Tactics.Effect.Tac
(FStar.InteractiveHelpers.Base.genv * FStar.InteractiveHelpers.Propositions.assertions) | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.bool",
"FStar.InteractiveHelpers.Base.genv",
"FStar.Pervasives.Native.option",
"FStar.Stubs.Reflection.Types.bv",
"FStar.InteractiveHelpers.Propositions.assertions",
"Prims.list",
"FStar.Pervasives.Native.tuple3",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Pervasives.Native.Mktuple2",
"FStar.InteractiveHelpers.Propositions.mk_assertions",
"FStar.Pervasives.Native.tuple2",
"FStar.Stubs.Reflection.Types.term",
"FStar.InteractiveHelpers.Propositions.__proj__Mkassertions__item__posts",
"FStar.InteractiveHelpers.Propositions.__proj__Mkassertions__item__pres",
"FStar.Tactics.Util.map",
"FStar.InteractiveHelpers.Base.apply_subst",
"FStar.InteractiveHelpers.Base.__proj__Mkgenv__item__env",
"Prims.unit",
"FStar.InteractiveHelpers.Base.print_dbg",
"Prims.string",
"Prims.op_Hat",
"FStar.List.Tot.Base.fold_left",
"FStar.Stubs.Tactics.V1.Builtins.term_to_string",
"FStar.InteractiveHelpers.Base.abv_to_string",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.fst",
"FStar.InteractiveHelpers.Output._split_subst_at_bv",
"FStar.Pervasives.Native.__proj__Some__item__v",
"FStar.Stubs.Tactics.V1.Builtins.pack",
"FStar.Stubs.Reflection.V1.Data.Tv_Var",
"FStar.InteractiveHelpers.Base.generate_shadowed_subst",
"FStar.InteractiveHelpers.Base.genv_to_string"
] | [] | false | true | false | false | false | let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
| print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
let pre_subst =
if Some? shadowed_bv
then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) = "(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n" in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg
then
(print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst));
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.opt_term_to_printout | val opt_term_to_printout (ge: genv) (prefix: string) (t: option term) : Tac string | val opt_term_to_printout (ge: genv) (prefix: string) (t: option term) : Tac string | let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix "" | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 97,
"start_col": 0,
"start_line": 94
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ge: FStar.InteractiveHelpers.Base.genv ->
prefix: Prims.string ->
t: FStar.Pervasives.Native.option FStar.Stubs.Reflection.Types.term
-> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"FStar.InteractiveHelpers.Base.genv",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.Stubs.Reflection.Types.term",
"FStar.InteractiveHelpers.Output.term_to_printout",
"FStar.InteractiveHelpers.Output.string_to_printout"
] | [] | false | true | false | false | false | let opt_term_to_printout (ge: genv) (prefix: string) (t: option term) : Tac string =
| match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix "" | false |
FStar.InteractiveHelpers.Output.fst | FStar.InteractiveHelpers.Output.result_to_printout | val result_to_printout (prefix: string) (res: export_result) : Tac string | val result_to_printout (prefix: string) (res: export_result) : Tac string | let result_to_printout (prefix:string) (res:export_result) :
Tac string =
let str = prefix ^ ":BEGIN\n" in
(* Note that the emacs commands will always look for fields for the error message
* and the pre/post assertions, so we need to generate them, even though they
* might be empty. *)
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in (* dummy environment - will not be used *)
Some err, ge, [], []
in
(* Error message *)
let str = str ^ error_message_to_printout prefix err in
(* Assertions *)
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%" | {
"file_name": "ulib/experimental/FStar.InteractiveHelpers.Output.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 142,
"start_col": 0,
"start_line": 124
} | module FStar.InteractiveHelpers.Output
open FStar.List
open FStar.Tactics
open FStar.Mul
open FStar.InteractiveHelpers.Base
open FStar.InteractiveHelpers.ExploreTerm
open FStar.InteractiveHelpers.Propositions
/// Facilities to output results to the IDE/emacs/whatever.
/// Contains datatypes and functions to carry information.
#push-options "--z3rlimit 15 --fuel 0 --ifuel 1"
(*** Convert terms to string *)
/// The important point is to handle variable shadowing properly, so that the
/// generated term is meaningful in the user context, or at least that it is clear
/// to the user that some variables are shadowed.
/// Introduce fresh variables for the variables shadowed in the current environment
/// and substitute them in the terms. Note that as the binding of the value returned
/// by a function application might shadow one of its parameters, we need to treat
/// differently the pre-assertions and the post-assertions. Moreover, we need to
/// keep track of which variables are shadowed for every assertion.
let rec _split_subst_at_bv (#a #b : Type) (x : bv) (subst : list ((bv & a) & b)) :
Tot (list ((bv & a) & b) & list ((bv & a) & b))
(decreases subst) =
match subst with
| [] -> [], []
| ((src, ty), tgt) :: subst' ->
if bv_eq x src then
[], subst'
else
let s1, s2 = _split_subst_at_bv x subst' in
((src, ty), tgt) :: s1, s2
val subst_shadowed_with_abs_in_assertions : bool -> genv -> option bv -> assertions -> Tac (genv & assertions)
let subst_shadowed_with_abs_in_assertions dbg ge shadowed_bv es =
(* When generating the substitution, we need to pay attention to the fact that
* the returned value potentially bound by a let may shadow another variable.
* We need to take this into account for the post-assertions (but not the
* pre-assertions). *)
print_dbg dbg ("subst_shadowed_with_abs_in_assertions:\n" ^ genv_to_string ge);
(* Generate the substitution *)
let ge1, subst = generate_shadowed_subst ge in
let post_subst = map (fun (src, ty, tgt) -> (src, ty), pack (Tv_Var tgt)) subst in
(* The current substitution is valid for the post-assertions: derive from it
* a substitution valid for the pre-assertions (just cut it where the bv
* shadowed by the return value appears). Note that because we might introduce
* dummy variables for the return value, it is not valid just to ignore
* the last substitution pair. *)
let pre_subst =
if Some? shadowed_bv then fst (_split_subst_at_bv (Some?.v shadowed_bv) post_subst)
else post_subst
in
let subst_to_string subst : Tac string =
let to_string ((x, ty), y) =
"(" ^ abv_to_string x ^ " -> " ^ term_to_string y ^ ")\n"
in
let str = map to_string subst in
List.Tot.fold_left (fun x y -> x ^ y) "" str
in
if dbg then
begin
print_dbg dbg ("- pre_subst:\n" ^ subst_to_string pre_subst);
print_dbg dbg ("- post_subst:\n" ^ subst_to_string post_subst)
end;
(* Apply *)
let apply = (fun s -> map (fun t -> apply_subst ge1.env t s)) in
let pres = apply pre_subst es.pres in
let posts = apply post_subst es.posts in
ge1, mk_assertions pres posts
(*** Convert propositions to string *)
/// Originally: we output the ``eterm_info`` and let the emacs commands do some
/// filtering and formatting. Now, we convert ``eterm_info`` to a ``assertions``.
/// Note that we also convert all the information to a string that we export at
/// once in order for the output not to be polluted by any other messages
/// (warning messages from F*, for example).
let string_to_printout (prefix data:string) : Tot string =
prefix ^ ":\n" ^ data ^ "\n"
let term_to_printout (ge:genv) (prefix:string) (t:term) : Tac string =
(* We need to look for abstract variables and abstract them away *)
let abs = abs_free_in ge t in
let abs_binders = List.Tot.map (fun (bv, t) -> mk_binder bv t) abs in
let abs_terms = map (fun (bv, _) -> pack (Tv_Var bv)) abs in
let t = mk_abs abs_binders t in
let t = mk_e_app t abs_terms in
string_to_printout prefix (term_to_string t)
let opt_term_to_printout (ge:genv) (prefix:string) (t:option term) : Tac string =
match t with
| Some t' -> term_to_printout ge prefix t'
| None -> string_to_printout prefix ""
let proposition_to_printout (ge:genv) (prefix:string) (p:proposition) : Tac string =
term_to_printout ge prefix p
let propositions_to_printout (ge:genv) (prefix:string) (pl:list proposition) : Tac string =
let prop_to_printout i p =
let prefix' = prefix ^ ":prop" ^ string_of_int i in
proposition_to_printout ge prefix' p
in
let str = string_to_printout (prefix ^ ":num") (string_of_int (List.Tot.length pl)) in
let concat_prop s_i p : Tac (string & int) =
let s, i = s_i in
s ^ prop_to_printout i p, i+1
in
let str, _ = fold_left concat_prop (str,0) pl in
str
let error_message_to_printout (prefix : string) (message : option string) : Tot string =
let msg = match message with | Some msg -> msg | _ -> "" in
string_to_printout (prefix ^ ":error") msg
/// Utility type and function to communicate the results to emacs.
noeq type export_result =
| ESuccess : ge:genv -> a:assertions -> export_result
| EFailure : err:string -> export_result | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.InteractiveHelpers.Propositions.fst.checked",
"FStar.InteractiveHelpers.ExploreTerm.fst.checked",
"FStar.InteractiveHelpers.Base.fst.checked"
],
"interface_file": false,
"source_file": "FStar.InteractiveHelpers.Output.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Propositions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.ExploreTerm",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.InteractiveHelpers",
"short_module": null
},
{
"abbrev": 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": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 15,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | prefix: Prims.string -> res: FStar.InteractiveHelpers.Output.export_result
-> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.string",
"FStar.InteractiveHelpers.Output.export_result",
"FStar.Pervasives.Native.option",
"FStar.InteractiveHelpers.Base.genv",
"Prims.list",
"FStar.InteractiveHelpers.Propositions.proposition",
"Prims.op_Hat",
"FStar.InteractiveHelpers.Output.propositions_to_printout",
"FStar.InteractiveHelpers.Output.error_message_to_printout",
"FStar.Pervasives.Native.tuple4",
"FStar.InteractiveHelpers.Propositions.assertions",
"FStar.Pervasives.Native.Mktuple4",
"FStar.Pervasives.Native.None",
"FStar.InteractiveHelpers.Propositions.__proj__Mkassertions__item__pres",
"FStar.InteractiveHelpers.Propositions.__proj__Mkassertions__item__posts",
"FStar.Pervasives.Native.Some",
"Prims.Nil",
"FStar.InteractiveHelpers.Base.mk_init_genv",
"FStar.Stubs.Reflection.Types.env",
"FStar.Stubs.Tactics.V1.Builtins.top_env"
] | [] | false | true | false | false | false | let result_to_printout (prefix: string) (res: export_result) : Tac string =
| let str = prefix ^ ":BEGIN\n" in
let err, ge, pres, posts =
match res with
| ESuccess ge a -> None, ge, a.pres, a.posts
| EFailure err ->
let ge = mk_init_genv (top_env ()) in
Some err, ge, [], []
in
let str = str ^ error_message_to_printout prefix err in
let str = str ^ propositions_to_printout ge (prefix ^ ":pres") pres in
let str = str ^ propositions_to_printout ge (prefix ^ ":posts") posts in
str ^ prefix ^ ":END\n" ^ "%FIH:FSTAR_META:END%" | false |
LList.ST.fst | LList.ST.empty | val empty (a:Type0) : llist a | val empty (a:Type0) : llist a | let empty a = null | {
"file_name": "share/steel/examples/steel/LList.ST.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 18,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2021 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.
Author: Aseem Rastogi
*)
module LList.ST
open Steel.Memory
open Steel.ST.Effect
open Steel.ST.Util
open Steel.ST.Reference
#set-options "--ide_id_info_off"
let rec is_list #a ll l : Tot vprop (decreases l) =
match l with
| [] -> pure (ll == null)
| hd::tl ->
exists_ (fun (node:llist_node a) ->
pts_to ll full_perm node
`star`
pure (node.data == hd)
`star`
is_list node.next tl) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "LList.ST.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"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": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "LList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LList",
"short_module": null
},
{
"abbrev": 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: Type0 -> LList.ST.llist a | Prims.Tot | [
"total"
] | [] | [
"Steel.ST.Reference.null",
"LList.ST.llist_node",
"LList.ST.llist"
] | [] | false | false | false | true | false | let empty a =
| null | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.size_k_w_256 | val size_k_w_256 : Prims.int | let size_k_w_256 = 64 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 18,
"start_col": 7,
"start_line": 18
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let size_k_w_256 =
| 64 | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.size_block_w_256 | val size_block_w_256 : Prims.int | let size_block_w_256 = 16 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 21,
"start_col": 0,
"start_line": 21
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let size_block_w_256 =
| 16 | false |
|
LList.ST.fst | LList.ST.is_list | val is_list (#a:Type0) (ll:llist a) (l:list a) : vprop | val is_list (#a:Type0) (ll:llist a) (l:list a) : vprop | let rec is_list #a ll l : Tot vprop (decreases l) =
match l with
| [] -> pure (ll == null)
| hd::tl ->
exists_ (fun (node:llist_node a) ->
pts_to ll full_perm node
`star`
pure (node.data == hd)
`star`
is_list node.next tl) | {
"file_name": "share/steel/examples/steel/LList.ST.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 34,
"end_line": 38,
"start_col": 0,
"start_line": 29
} | (*
Copyright 2021 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.
Author: Aseem Rastogi
*)
module LList.ST
open Steel.Memory
open Steel.ST.Effect
open Steel.ST.Util
open Steel.ST.Reference
#set-options "--ide_id_info_off" | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "LList.ST.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"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": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "LList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LList",
"short_module": null
},
{
"abbrev": 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 | ll: LList.ST.llist a -> l: Prims.list a -> Prims.Tot Steel.Effect.Common.vprop | Prims.Tot | [
"",
"total"
] | [] | [
"LList.ST.llist",
"Prims.list",
"Steel.ST.Util.pure",
"Prims.eq2",
"Steel.ST.Reference.ref",
"LList.ST.llist_node",
"Steel.ST.Reference.null",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.Reference.pts_to",
"Steel.FractionalPermission.full_perm",
"LList.ST.__proj__Mkllist_node__item__data",
"LList.ST.is_list",
"LList.ST.__proj__Mkllist_node__item__next",
"Steel.Effect.Common.vprop"
] | [
"recursion"
] | false | false | false | true | false | let rec is_list #a ll l : Tot vprop (decreases l) =
| match l with
| [] -> pure (ll == null)
| hd :: tl ->
exists_ (fun (node: llist_node a) ->
((pts_to ll full_perm node) `star` (pure (node.data == hd))) `star` (is_list node.next tl)) | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.block_length | val block_length : Prims.int | let block_length =
4 (*word_length a*) * size_block_w_256 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 24,
"start_col": 0,
"start_line": 23
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [
"FStar.Mul.op_Star",
"Vale.SHA.SHA_helpers.size_block_w_256"
] | [] | false | false | false | true | false | let block_length =
| 4 * size_block_w_256 | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.block_w | val block_w : Type0 | let block_w = m:seq word {length m = size_block_w_256} | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 25,
"start_col": 0,
"start_line": 25
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length = | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.SHA.SHA_helpers.word",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.size_block_w_256"
] | [] | false | false | false | true | true | let block_w =
| m: seq word {length m = size_block_w_256} | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.hash256 | val hash256 : Type0 | let hash256 = m:Seq.seq word {Seq.length m = 8} | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.SHA.SHA_helpers.word",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length"
] | [] | false | false | false | true | true | let hash256 =
| m: Seq.seq word {Seq.length m = 8} | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.counter | val counter : Type0 | let counter = nat | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 26,
"start_col": 0,
"start_line": 26
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat"
] | [] | false | false | false | true | true | let counter =
| nat | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.ws_partial_reveal | val ws_partial_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.ws_partial == Vale.SHA.SHA_helpers.ws_partial_def) | let ws_partial_reveal = opaque_revealer (`%ws_partial) ws_partial ws_partial_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 92,
"end_line": 114,
"start_col": 12,
"start_line": 114
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
(* Proof work for the SHA256_msg* instructions *)
let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0
val ws_partial_def (t:counter) (block:block_w) : quad32 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.ws_partial == Vale.SHA.SHA_helpers.ws_partial_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.ws_partial",
"Vale.SHA.SHA_helpers.ws_partial_def"
] | [] | true | false | true | false | false | let ws_partial_reveal =
| opaque_revealer (`%ws_partial) ws_partial ws_partial_def | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.ws_partial | val ws_partial : _: Vale.SHA.SHA_helpers.counter -> _: Vale.SHA.SHA_helpers.block_w -> Vale.Def.Types_s.quad32 | let ws_partial = opaque_make ws_partial_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 113,
"start_col": 19,
"start_line": 113
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
(* Proof work for the SHA256_msg* instructions *)
let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Vale.SHA.SHA_helpers.counter -> _: Vale.SHA.SHA_helpers.block_w -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.ws_partial_def"
] | [] | false | false | false | true | false | let ws_partial =
| opaque_make ws_partial_def | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.bytes_blocks | val bytes_blocks : Type0 | let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 } | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 38,
"start_col": 0,
"start_line": 37
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.SHA.SHA_helpers.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.byte",
"Vale.SHA.SHA_helpers.block_length"
] | [] | false | false | false | true | true | let bytes_blocks =
| l: bytes{Seq.length l % block_length = 0} | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.update_multi_opaque_vale | val update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256 | val update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256 | let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 110,
"end_line": 61,
"start_col": 0,
"start_line": 60
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) = | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | hash: Vale.SHA.SHA_helpers.hash256 -> blocks: Vale.SHA.SHA_helpers.bytes
-> Vale.SHA.SHA_helpers.hash256 | Prims.Tot | [
"total"
] | [] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.bytes",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.byte",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.SHA.SHA_helpers.update_multi_opaque",
"Vale.SHA.SHA_helpers.bytes_blocks",
"Prims.bool"
] | [] | false | false | false | true | false | let update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256 =
| if length blocks % size_k_w_256 = 0
then
let b:bytes_blocks = blocks in
update_multi_opaque hash b
else hash | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.repeat_range_vale | val repeat_range_vale : max: Prims.nat{max < Vale.SHA.SHA_helpers.size_k_w_256} ->
block: Vale.SHA.SHA_helpers.block_w ->
hash: Vale.SHA.SHA_helpers.hash256
-> Vale.SHA.SHA_helpers.hash256 | let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 64,
"end_line": 56,
"start_col": 0,
"start_line": 55
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
max: Prims.nat{max < Vale.SHA.SHA_helpers.size_k_w_256} ->
block: Vale.SHA.SHA_helpers.block_w ->
hash: Vale.SHA.SHA_helpers.hash256
-> Vale.SHA.SHA_helpers.hash256 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Spec.Loops.repeat_range",
"Vale.SHA.SHA_helpers.shuffle_core_opaque"
] | [] | false | false | false | false | false | let repeat_range_vale (max: nat{max < size_k_w_256}) (block: block_w) (hash: hash256) =
| Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash | false |
|
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.lemma_repeat_range_0_vale | val lemma_repeat_range_0_vale (block: block_w) (hash: hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) | val lemma_repeat_range_0_vale (block: block_w) (hash: hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) | let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 59,
"start_col": 0,
"start_line": 57
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | block: Vale.SHA.SHA_helpers.block_w -> hash: Vale.SHA.SHA_helpers.hash256
-> FStar.Pervasives.Lemma
(ensures
Spec.Loops.repeat_range 0 0 (Vale.SHA.SHA_helpers.shuffle_core_opaque block) hash == hash) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Spec.Loops.repeat_range_base",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Spec.Loops.repeat_range",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_repeat_range_0_vale (block: block_w) (hash: hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
| Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.ws_quad32 | val ws_quad32 (t: counter) (block: block_w) : quad32 | val ws_quad32 (t: counter) (block: block_w) : quad32 | let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 110,
"start_col": 0,
"start_line": 103
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.SHA.SHA_helpers.counter -> block: Vale.SHA.SHA_helpers.block_w -> Vale.Def.Types_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.op_Addition",
"Prims.bool",
"Vale.Def.Types_s.quad32"
] | [] | false | false | false | true | false | let ws_quad32 (t: counter) (block: block_w) : quad32 =
| if t < size_k_w_256 - 3
then
Mkfour (ws_opaque block t)
(ws_opaque block (t + 1))
(ws_opaque block (t + 2))
(ws_opaque block (t + 3))
else Mkfour 0 0 0 0 | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.k_reqs | val k_reqs (k_seq: seq quad32) : prop0 | val k_reqs (k_seq: seq quad32) : prop0 | let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 142,
"start_col": 0,
"start_line": 136
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
(* Proof work for the SHA256_msg* instructions *)
let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0
val ws_partial_def (t:counter) (block:block_w) : quad32
[@"opaque_to_smt"] let ws_partial = opaque_make ws_partial_def
irreducible let ws_partial_reveal = opaque_revealer (`%ws_partial) ws_partial ws_partial_def
// Top-level proof for the SHA256_msg1 instruction
val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
// Top-level proof for the SHA256_msg2 instruction
val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | k_seq: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Division",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"Prims.op_LessThanOrEqual",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.op_String_Access",
"Vale.SHA.SHA_helpers.word_to_nat32",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.k",
"FStar.Mul.op_Star",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Prims.op_Addition",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"FStar.Seq.Base.index",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | true | false | let k_reqs (k_seq: seq quad32) : prop0 =
| length k_seq == size_k_w_256 / 4 /\
(forall i. {:pattern (index k_seq i)}
0 <= i /\ i < (size_k_w_256 / 4) ==>
(k_seq.[ i ]).lo0 == word_to_nat32 (k.[ 4 * i ]) /\
(k_seq.[ i ]).lo1 == word_to_nat32 (k.[ 4 * i + 1 ]) /\
(k_seq.[ i ]).hi2 == word_to_nat32 (k.[ 4 * i + 2 ]) /\
(k_seq.[ i ]).hi3 == word_to_nat32 (k.[ 4 * i + 3 ])) | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.quads_to_block | val quads_to_block (qs: seq quad32) : block_w | val quads_to_block (qs: seq quad32) : block_w | let quads_to_block (qs:seq quad32) : block_w
=
let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_LE qs in
let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in
init 16 f | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 148,
"start_col": 0,
"start_line": 144
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
(* Proof work for the SHA256_msg* instructions *)
let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0
val ws_partial_def (t:counter) (block:block_w) : quad32
[@"opaque_to_smt"] let ws_partial = opaque_make ws_partial_def
irreducible let ws_partial_reveal = opaque_revealer (`%ws_partial) ws_partial ws_partial_def
// Top-level proof for the SHA256_msg1 instruction
val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
// Top-level proof for the SHA256_msg2 instruction
val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
(* Abbreviations and lemmas for the code itself *)
let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | qs: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Vale.SHA.SHA_helpers.block_w | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.init",
"Vale.SHA.SHA_helpers.word",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.nat32_to_word",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.op_String_Access",
"Prims.bool",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Prims.int",
"Prims.op_Multiply",
"Vale.Def.Words_s.four",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Vale.SHA.SHA_helpers.block_w"
] | [] | false | false | false | true | false | let quads_to_block (qs: seq quad32) : block_w =
| let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_LE qs in
let f (n: nat{n < 16}) : word =
nat32_to_word (if n < length nat32_seq then nat32_seq.[ n ] else 0)
in
init 16 f | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.update_multi_quads | val update_multi_quads (s: seq quad32) (hash_orig: hash256) : Tot (hash256) (decreases (length s)) | val update_multi_quads (s: seq quad32) (hash_orig: hash256) : Tot (hash256) (decreases (length s)) | let rec update_multi_quads (s:seq quad32) (hash_orig:hash256) : Tot (hash256) (decreases (length s))
=
if length s < 4 then
hash_orig
else
let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 8,
"end_line": 196,
"start_col": 0,
"start_line": 188
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
(* Proof work for the SHA256_msg* instructions *)
let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0
val ws_partial_def (t:counter) (block:block_w) : quad32
[@"opaque_to_smt"] let ws_partial = opaque_make ws_partial_def
irreducible let ws_partial_reveal = opaque_revealer (`%ws_partial) ws_partial ws_partial_def
// Top-level proof for the SHA256_msg1 instruction
val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
// Top-level proof for the SHA256_msg2 instruction
val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
(* Abbreviations and lemmas for the code itself *)
let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3]))
let quads_to_block (qs:seq quad32) : block_w
=
let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_LE qs in
let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in
init 16 f
val lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block))
(*
#push-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures (let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block))
=
//reveal_opaque ws;
()
#pop-options
*)
val update_block (hash:hash256) (block:block_w): hash256
val update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 size_k_w_256 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> hash_orig: Vale.SHA.SHA_helpers.hash256
-> Prims.Tot Vale.SHA.SHA_helpers.hash256 | Prims.Tot | [
"total",
""
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.hash256",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Prims.bool",
"Vale.SHA.SHA_helpers.update_block",
"Vale.SHA.SHA_helpers.quads_to_block",
"Vale.SHA.SHA_helpers.update_multi_quads",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | true | false | let rec update_multi_quads (s: seq quad32) (hash_orig: hash256)
: Tot (hash256) (decreases (length s)) =
| if length s < 4
then hash_orig
else
let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
hash | false |
Vale.SHA.SHA_helpers.fsti | Vale.SHA.SHA_helpers.le_bytes_to_hash | val le_bytes_to_hash (b: seq nat8) : hash256 | val le_bytes_to_hash (b: seq nat8) : hash256 | let le_bytes_to_hash (b:seq nat8) : hash256 =
if length b <> 32 then
(let f (n:nat{n < 8}) : word = nat32_to_word 0 in
init 8 f)
else (
let open Vale.Def.Words.Seq_s in
Vale.Lib.Seqs_s.seq_map nat32_to_word (seq_nat8_to_seq_nat32_LE b)
) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 229,
"start_col": 0,
"start_line": 222
} | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
unfold let (.[]) = FStar.Seq.index
#reset-options "--max_fuel 0 --max_ifuel 0"
// Specialize these definitions (from Spec.SHA2.fst) for SHA256
unfold let size_k_w_256 = 64
val word:Type0
(* Number of words for a block size *)
let size_block_w_256 = 16
(* Define the size block in bytes *)
let block_length =
4 (*word_length a*) * size_block_w_256
let block_w = m:seq word {length m = size_block_w_256}
let counter = nat
val k : (s:seq word {length s = size_k_w_256})
let hash256 = m:Seq.seq word {Seq.length m = 8}
val reveal_word (u:unit) : Lemma (word == Lib.IntTypes.uint32)
(* Input data. *)
type byte = UInt8.t
type bytes = Seq.seq byte
(* Input data, multiple of a block length. *)
let bytes_blocks =
l:bytes { Seq.length l % block_length = 0 }
// Hide various SHA2 definitions
val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
// Hide some functions that operate on words & bytes
val word_to_nat32 (x:word) : nat32
val nat32_to_word (x:nat32) : word
val byte_to_nat8 (b:byte) : nat8
val nat8_to_byte (b:nat8) : byte
// Work around some limitations in Vale's support for dependent types
//unfold let bytes_blocks256 = bytes_blocks SHA2_256
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) =
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let lemma_repeat_range_0_vale (block:block_w) (hash:hash256)
: Lemma (Spec.Loops.repeat_range 0 0 (shuffle_core_opaque block) hash == hash) =
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 =
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
// Top-level proof for the SHA256_rnds2 instruction
val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
(* Proof work for the SHA256_msg* instructions *)
let ws_quad32 (t:counter) (block:block_w) : quad32 =
if t < size_k_w_256 - 3 then
Mkfour (ws_opaque block t)
(ws_opaque block (t+1))
(ws_opaque block (t+2))
(ws_opaque block (t+3))
else
Mkfour 0 0 0 0
val ws_partial_def (t:counter) (block:block_w) : quad32
[@"opaque_to_smt"] let ws_partial = opaque_make ws_partial_def
irreducible let ws_partial_reveal = opaque_revealer (`%ws_partial) ws_partial ws_partial_def
// Top-level proof for the SHA256_msg1 instruction
val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
// Top-level proof for the SHA256_msg2 instruction
val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
(* Abbreviations and lemmas for the code itself *)
let k_reqs (k_seq:seq quad32) : prop0 =
length k_seq == size_k_w_256 / 4 /\
(forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==>
(k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\
(k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\
(k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\
(k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3]))
let quads_to_block (qs:seq quad32) : block_w
=
let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_LE qs in
let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in
init 16 f
val lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block))
(*
#push-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures (let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block))
=
//reveal_opaque ws;
()
#pop-options
*)
val update_block (hash:hash256) (block:block_w): hash256
val update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 size_k_w_256 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
let rec update_multi_quads (s:seq quad32) (hash_orig:hash256) : Tot (hash256) (decreases (length s))
=
if length s < 4 then
hash_orig
else
let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
hash
val lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq byte) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % size_k_w_256 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.Loops.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.SHA_helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": 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": 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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> Vale.SHA.SHA_helpers.hash256 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat8",
"Prims.op_disEquality",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Seq.Base.init",
"Vale.SHA.SHA_helpers.word",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Prims.bool",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"Vale.SHA.SHA_helpers.hash256"
] | [] | false | false | false | true | false | let le_bytes_to_hash (b: seq nat8) : hash256 =
| if length b <> 32
then
(let f (n: nat{n < 8}) : word = nat32_to_word 0 in
init 8 f)
else
(let open Vale.Def.Words.Seq_s in
Vale.Lib.Seqs_s.seq_map nat32_to_word (seq_nat8_to_seq_nat32_LE b)) | false |
Steel.ST.GhostReference.fsti | Steel.ST.GhostReference.with_local | val with_local
(#t: Type)
(init: Ghost.erased t)
(#pre: vprop)
(#ret_t: Type)
(#post: (ret_t -> vprop))
(body:
(r: ref t
-> STT ret_t
((pts_to r full_perm init) `star` pre)
(fun v -> (exists_ (pts_to r full_perm)) `star` (post v))))
: STF ret_t pre post True (fun _ -> True) | val with_local
(#t: Type)
(init: Ghost.erased t)
(#pre: vprop)
(#ret_t: Type)
(#post: (ret_t -> vprop))
(body:
(r: ref t
-> STT ret_t
((pts_to r full_perm init) `star` pre)
(fun v -> (exists_ (pts_to r full_perm)) `star` (post v))))
: STF ret_t pre post True (fun _ -> True) | let with_local
(#t: Type)
(init: Ghost.erased t)
(#pre: vprop)
(#ret_t: Type)
(#post: ret_t -> vprop)
(body: (r: ref t) ->
STT ret_t
(pts_to r full_perm init `star` pre)
(fun v -> exists_ (pts_to r full_perm) `star` post v)
)
: STF ret_t pre post True (fun _ -> True)
= let r = alloc init in
let v = body r in
let _ = elim_exists () in
free r;
return v | {
"file_name": "lib/steel/Steel.ST.GhostReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 10,
"end_line": 174,
"start_col": 0,
"start_line": 158
} | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.GhostReference
open FStar.Ghost
open Steel.ST.Util
(** This module provides a *ghost* reference whose ownership is
controlled using fractional permissions.
Most of its functionality is identical to Steel.ST.Reference,
except it uses the STGhost effect.
*)
/// The main ref type.
///
/// It's in universe zero, so refs can be stored in the heap, you can
/// have [ref (ref a)] etc.
///
/// The type is marked erasable, so [ref a] values are extracted to [()]
[@@ erasable]
val ref (a:Type u#0)
: Type u#0
val dummy_ref (a: Type) : Tot (ref a)
/// The main representation predicate
val pts_to (#a:_)
(r:ref a)
([@@@smt_fallback] p:perm)
([@@@smt_fallback] v:a)
: vprop
/// A ref can point to at most one value
val pts_to_injective_eq (#a:_)
(#u:_)
(#p #q:_)
(#v0 #v1:a)
(r:ref a)
: STGhost unit u
(pts_to r p v0 `star` pts_to r q v1)
(fun _ -> pts_to r p v0 `star` pts_to r q v0)
(requires True)
(ensures fun _ -> v0 == v1)
/// A permission is always no greater than one
val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a)
: STGhost unit u
(pts_to r p v)
(fun _ -> pts_to r p v)
True
(fun _ -> p `lesser_equal_perm` full_perm)
/// Allocating a ghost reference, with an erased initial value
val alloc (#a:Type)
(#u:_)
(x:erased a)
: STGhostT (ref a) u
emp
(fun r -> pts_to r full_perm x)
/// Reading a ghost reference only provides an erased value
val read (#a:Type)
(#u:_)
(#p:perm)
(#v:erased a)
(r:ref a)
: STGhost (erased a) u
(pts_to r p v)
(fun x -> pts_to r p x)
(requires True)
(ensures fun x -> x == v)
/// Updating the contents of a fully owned ghost reference with an
/// erased value
val write (#a:Type)
(#u:_)
(#v:erased a)
(r:ref a)
(x:erased a)
: STGhostT unit u
(pts_to r full_perm v)
(fun _ -> pts_to r full_perm x)
/// Splitting ownership of a ghost reference
val share_gen
(#t: Type)
(#opened: _)
(#p: perm)
(#v: t)
(r: ref t)
(p1 p2: perm)
: STGhost unit opened
(pts_to r p v)
(fun _ -> pts_to r p1 v `star` pts_to r p2 v)
(p == p1 `sum_perm` p2)
(fun _ -> True)
val share (#a:Type)
(#u:_)
(#p:perm)
(#x:erased a)
(r:ref a)
: STGhostT unit u
(pts_to r p x)
(fun _ -> pts_to r (half_perm p) x `star`
pts_to r (half_perm p) x)
/// Combining ownership of a ghost reference
/// -- the ensures clause internalizes a use of pts_to_injective_eq
val gather (#a:Type)
(#u:_)
(#p0 #p1:perm)
(#x0 #x1:erased a)
(r:ref a)
: STGhost unit u
(pts_to r p0 x0 `star` pts_to r p1 x1)
(fun _ -> pts_to r (sum_perm p0 p1) x0)
(requires True)
(ensures fun _ -> x0 == x1)
/// Technically, a ghost reference need not be freed (since it is
/// never allocated anyway). But, we provide a free nonetheless. It is
/// equivalent to just dropping the predicate.
val free (#a:Type0)
(#u:_)
(#v:erased a)
(r:ref a)
: STGhostT unit u
(pts_to r full_perm v)
(fun _ -> emp)
/// Executes a code block with a ghost reference temporarily
/// allocated. This function is declared in the `STF` effect so
/// that the pre- and post-resources can be properly inferred by the
/// Steel tactic from the caller's context.
///
/// By virtue of `alloc` and `free` being STGhost
/// functions, `with_local init body` simply extracts as `body _`.
///
/// This combinator is defined only to mirror its Steel.ST.Reference
/// counterpart. | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.ST.GhostReference.fsti"
} | [
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | init: FStar.Ghost.erased t -> body: (r: Steel.ST.GhostReference.ref t -> Steel.ST.Effect.STT ret_t)
-> Steel.ST.Effect.STF ret_t | Steel.ST.Effect.STF | [] | [] | [
"FStar.Ghost.erased",
"Steel.Effect.Common.vprop",
"Steel.ST.GhostReference.ref",
"Steel.Effect.Common.star",
"Steel.ST.GhostReference.pts_to",
"Steel.FractionalPermission.full_perm",
"FStar.Ghost.reveal",
"Steel.ST.Util.exists_",
"Steel.ST.Util.return",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"Prims.unit",
"Steel.ST.GhostReference.free",
"Steel.ST.Util.elim_exists",
"Steel.ST.GhostReference.alloc",
"Prims.l_True"
] | [] | false | true | false | false | false | let with_local
(#t: Type)
(init: Ghost.erased t)
(#pre: vprop)
(#ret_t: Type)
(#post: (ret_t -> vprop))
(body:
(r: ref t
-> STT ret_t
((pts_to r full_perm init) `star` pre)
(fun v -> (exists_ (pts_to r full_perm)) `star` (post v))))
: STF ret_t pre post True (fun _ -> True) =
| let r = alloc init in
let v = body r in
let _ = elim_exists () in
free r;
return v | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.linv_ctx | val linv_ctx (a: LSeq.lseq uint64 0) : Type0 | val linv_ctx (a: LSeq.lseq uint64 0) : Type0 | let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | a: Lib.Sequence.lseq Lib.IntTypes.uint64 0 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Prims.l_True"
] | [] | false | false | false | false | true | let linv_ctx (a: LSeq.lseq uint64 0) : Type0 =
| True | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.one_mod | val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid | val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid | let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0) | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | Hacl.Impl.Exponentiation.Definitions.lone_st Lib.IntTypes.U64
5ul
0ul
Hacl.Impl.K256.Finv.mk_to_k256_prime_comm_monoid | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.__uint_to_t",
"Hacl.K256.Field.make_u52_5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64",
"Prims.unit"
] | [] | false | false | false | false | false | let one_mod ctx one =
| make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0) | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.linv | val linv (a: LSeq.lseq uint64 5) : Type0 | val linv (a: LSeq.lseq uint64 5) : Type0 | let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4]) | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 29,
"start_col": 0,
"start_line": 27
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | a: Lib.Sequence.lseq Lib.IntTypes.uint64 5 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.K256.Field.inv_lazy_reduced2_5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.Sequence.op_String_Access"
] | [] | false | false | false | false | true | let linv (a: LSeq.lseq uint64 5) : Type0 =
| let open Lib.Sequence in inv_lazy_reduced2_5 (a.[ 0 ], a.[ 1 ], a.[ 2 ], a.[ 3 ], a.[ 4 ]) | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.mk_k256_prime_concrete_ops | val mk_k256_prime_concrete_ops:BE.concrete_ops U64 5ul 0ul | val mk_k256_prime_concrete_ops:BE.concrete_ops U64 5ul 0ul | let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
} | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 68,
"start_col": 0,
"start_line": 63
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | Hacl.Impl.Exponentiation.Definitions.concrete_ops Lib.IntTypes.U64
(5ul <: FStar.UInt32.t)
(0ul <: FStar.UInt32.t) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Exponentiation.Definitions.Mkconcrete_ops",
"Lib.IntTypes.U64",
"FStar.UInt32.uint_to_t",
"FStar.Ghost.hide",
"Hacl.Impl.Exponentiation.Definitions.to_comm_monoid",
"Hacl.Impl.K256.Finv.mk_to_k256_prime_comm_monoid",
"Hacl.Impl.K256.Finv.one_mod",
"Hacl.Impl.K256.Finv.mul_mod",
"Hacl.Impl.K256.Finv.sqr_mod"
] | [] | false | false | false | false | false | let mk_k256_prime_concrete_ops:BE.concrete_ops U64 5ul 0ul =
| { BE.to = mk_to_k256_prime_comm_monoid; BE.lone = one_mod; BE.lmul = mul_mod; BE.lsqr = sqr_mod } | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.fsquare_times_in_place | val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b)) | val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b)) | let fsquare_times_in_place out b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 81,
"start_col": 0,
"start_line": 78
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x
inline_for_extraction noextract
let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
}
val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | out: Hacl.K256.Field.felem -> b: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Lib.IntTypes.size_t",
"Hacl.Impl.Exponentiation.lexp_pow2_in_place",
"Lib.IntTypes.U64",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.Finv.mk_k256_prime_concrete_ops",
"Lib.Buffer.null",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Prims.unit",
"Spec.Exponentiation.exp_pow2_lemma",
"Spec.K256.PointOps.felem",
"Hacl.Spec.K256.Finv.mk_nat_mod_concrete_ops",
"Hacl.K256.Field.feval",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let fsquare_times_in_place out b =
| let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b | false |
InsertionSort2.fst | InsertionSort2.insert' | val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a) | val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a) | let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k) | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 29,
"end_line": 29,
"start_col": 0,
"start_line": 24
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 -> l: Prims.list a -> k: (_: a -> Prims.int) -> Prims.list a | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"Prims.Cons",
"Prims.Nil",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"InsertionSort2.insert'"
] | [
"recursion"
] | false | false | false | false | false | let rec insert' #a x l k =
| match l with
| [] -> [x]
| hd :: tl -> if k x <= k hd then x :: l else hd :: (insert' x tl k) | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.mk_to_k256_prime_comm_monoid | val mk_to_k256_prime_comm_monoid:BE.to_comm_monoid U64 5ul 0ul | val mk_to_k256_prime_comm_monoid:BE.to_comm_monoid U64 5ul 0ul | let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
} | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 44,
"start_col": 0,
"start_line": 38
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4]) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | Hacl.Impl.Exponentiation.Definitions.to_comm_monoid Lib.IntTypes.U64
(5ul <: FStar.UInt32.t)
(0ul <: FStar.UInt32.t) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Impl.Exponentiation.Definitions.Mkto_comm_monoid",
"Lib.IntTypes.U64",
"FStar.UInt32.uint_to_t",
"Spec.K256.PointOps.felem",
"Hacl.Spec.K256.Finv.nat_mod_comm_monoid",
"Hacl.Impl.K256.Finv.linv_ctx",
"Hacl.Impl.K256.Finv.linv",
"Hacl.Impl.K256.Finv.refl"
] | [] | false | false | false | false | false | let mk_to_k256_prime_comm_monoid:BE.to_comm_monoid U64 5ul 0ul =
| {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl
} | false |
InsertionSort2.fst | InsertionSort2.insert'_stable | val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k)) | val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k)) | let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 49,
"start_col": 0,
"start_line": 44
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 -> l: Prims.list a -> k: (_: a -> Prims.int)
-> FStar.Pervasives.Lemma (requires GenericSort.sorted l k)
(ensures GenericStability.stable (InsertionSort2.insert' x l k) (x :: l) k) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"Prims.op_LessThanOrEqual",
"GenericStability.filter_eq_append",
"Prims.Cons",
"Prims.Nil",
"InsertionSort2.insert'",
"Prims.bool",
"InsertionSort2.insert'_stable",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec insert'_stable #a x l k =
| match l with
| [] -> ()
| hd :: tl -> if k x <= k hd then filter_eq_append [x] (insert' x tl k) k else insert'_stable x tl k | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.fexp_223 | val fexp_223 (x3 x44 x88 tmp:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h x44 /\ live h x88 /\ live h tmp /\
disjoint x3 x44 /\ disjoint x3 x88 /\ disjoint x3 tmp /\
disjoint x44 x88 /\ disjoint x44 tmp /\ disjoint x88 tmp /\
inv_lazy_reduced2 h x3 /\ inv_lazy_reduced2 h x44)
(ensures fun h0 _ h1 -> modifies (loc x88 |+| loc tmp) h0 h1 /\
(let _x3 = feval h0 x3 in
let _x44 = feval h0 x44 in
let _x88 = S.fmul (SI.fsquare_times _x44 44) _x44 in
let _x176 = S.fmul (SI.fsquare_times _x88 88) _x88 in
let _x220 = S.fmul (SI.fsquare_times _x176 44) _x44 in
let _x223 = S.fmul (SI.fsquare_times _x220 3) _x3 in
feval h1 tmp == _x223 /\ feval h1 x88 == _x88 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x88)) | val fexp_223 (x3 x44 x88 tmp:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h x44 /\ live h x88 /\ live h tmp /\
disjoint x3 x44 /\ disjoint x3 x88 /\ disjoint x3 tmp /\
disjoint x44 x88 /\ disjoint x44 tmp /\ disjoint x88 tmp /\
inv_lazy_reduced2 h x3 /\ inv_lazy_reduced2 h x44)
(ensures fun h0 _ h1 -> modifies (loc x88 |+| loc tmp) h0 h1 /\
(let _x3 = feval h0 x3 in
let _x44 = feval h0 x44 in
let _x88 = S.fmul (SI.fsquare_times _x44 44) _x44 in
let _x176 = S.fmul (SI.fsquare_times _x88 88) _x88 in
let _x220 = S.fmul (SI.fsquare_times _x176 44) _x44 in
let _x223 = S.fmul (SI.fsquare_times _x220 3) _x3 in
feval h1 tmp == _x223 /\ feval h1 x88 == _x88 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x88)) | let fexp_223 x3 x44 x88 tmp =
let h7 = ST.get () in
fsquare_times x88 x44 44ul;
fmul x88 x88 x44; // x88 = S.fmul (fsquare_times x44 44) x44
let h8 = ST.get () in
assert (feval h8 x88 == S.fmul (SI.fsquare_times (feval h7 x44) 44) (feval h7 x44));
fsquare_times tmp x88 88ul;
fmul tmp tmp x88; // tmp = x176 = S.fmul (fsquare_times x88 88) x88
let h9 = ST.get () in
assert (feval h9 tmp == S.fmul (SI.fsquare_times (feval h8 x88) 88) (feval h8 x88));
fsquare_times_in_place tmp 44ul;
fmul tmp tmp x44; // tmp = x220 = S.fmul (fsquare_times x176 44) x44
let h10 = ST.get () in
assert (feval h10 tmp == S.fmul (SI.fsquare_times (feval h9 tmp) 44) (feval h7 x44));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x223 = S.fmul (fsquare_times x220 3) x3
let h11 = ST.get () in
assert (feval h11 tmp == S.fmul (SI.fsquare_times (feval h10 tmp) 3) (feval h7 x3)) | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 85,
"end_line": 182,
"start_col": 0,
"start_line": 162
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x
inline_for_extraction noextract
let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
}
val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b))
[@CInline]
let fsquare_times_in_place out b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b
val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b))
[@CInline]
let fsquare_times out a b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 a) (v b);
BE.lexp_pow2 5ul 0ul mk_k256_prime_concrete_ops (null uint64) a b out
inline_for_extraction noextract
val fexp_44 (x2 x3 x22 x44 tmp:felem) : Stack unit
(requires fun h ->
live h x2 /\ live h x3 /\ live h x22 /\ live h x44 /\ live h tmp /\
disjoint x2 x3 /\ disjoint x2 x22 /\ disjoint x2 x44 /\
disjoint x2 tmp /\ disjoint x3 x22 /\ disjoint x3 x44 /\
disjoint x3 tmp /\ disjoint x22 x44 /\ disjoint x22 tmp /\
disjoint x44 tmp /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h x3)
(ensures fun h0 _ h1 -> modifies (loc x22 |+| loc x44 |+| loc tmp) h0 h1 /\
(let _x2 = feval h0 x2 in
let _x3 = feval h0 x3 in
let _x6 = S.fmul (SI.fsquare_times _x3 3) _x3 in
let _x9 = S.fmul (SI.fsquare_times _x6 3) _x3 in
let _x11 = S.fmul (SI.fsquare_times _x9 2) _x2 in
let _x22 = S.fmul (SI.fsquare_times _x11 11) _x11 in
let _x44 = S.fmul (SI.fsquare_times _x22 22) _x22 in
feval h1 tmp == _x11 /\ feval h1 x22 == _x22 /\ feval h1 x44 == _x44 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x22 /\ inv_lazy_reduced2 h1 x44))
let fexp_44 x2 x3 x22 x44 tmp =
let h2 = ST.get () in
fsquare_times tmp x3 3ul;
fmul tmp tmp x3; // tmp = x6 = S.fmul (fsquare_times x3 3) x3
let h3 = ST.get () in
assert (feval h3 tmp == S.fmul (SI.fsquare_times (feval h2 x3) 3) (feval h2 x3));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x9 = S.fmul (fsquare_times x6 3) x3
let h4 = ST.get () in
assert (feval h4 tmp == S.fmul (SI.fsquare_times (feval h3 tmp) 3) (feval h2 x3));
fsquare_times_in_place tmp 2ul;
fmul tmp tmp x2; // tmp = x11 = S.fmul (fsquare_times x9 2) x2
let h5 = ST.get () in
assert (feval h5 tmp == S.fmul (SI.fsquare_times (feval h4 tmp) 2) (feval h2 x2));
fsquare_times x22 tmp 11ul;
fmul x22 x22 tmp; // x22 = S.fmul (fsquare_times x11 11) x11
let h6 = ST.get () in
assert (feval h6 x22 == S.fmul (SI.fsquare_times (feval h5 tmp) 11) (feval h5 tmp));
fsquare_times x44 x22 22ul;
fmul x44 x44 x22; // x44 = S.fmul (fsquare_times x22 22) x22
let h7 = ST.get () in
assert (feval h7 x44 == S.fmul (SI.fsquare_times (feval h6 x22) 22) (feval h6 x22))
inline_for_extraction noextract
val fexp_223 (x3 x44 x88 tmp:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h x44 /\ live h x88 /\ live h tmp /\
disjoint x3 x44 /\ disjoint x3 x88 /\ disjoint x3 tmp /\
disjoint x44 x88 /\ disjoint x44 tmp /\ disjoint x88 tmp /\
inv_lazy_reduced2 h x3 /\ inv_lazy_reduced2 h x44)
(ensures fun h0 _ h1 -> modifies (loc x88 |+| loc tmp) h0 h1 /\
(let _x3 = feval h0 x3 in
let _x44 = feval h0 x44 in
let _x88 = S.fmul (SI.fsquare_times _x44 44) _x44 in
let _x176 = S.fmul (SI.fsquare_times _x88 88) _x88 in
let _x220 = S.fmul (SI.fsquare_times _x176 44) _x44 in
let _x223 = S.fmul (SI.fsquare_times _x220 3) _x3 in
feval h1 tmp == _x223 /\ feval h1 x88 == _x88 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x88)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 |
x3: Hacl.K256.Field.felem ->
x44: Hacl.K256.Field.felem ->
x88: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Prims._assert",
"Prims.eq2",
"Spec.K256.PointOps.felem",
"Hacl.K256.Field.feval",
"Spec.K256.PointOps.fmul",
"Hacl.Spec.K256.Finv.fsquare_times",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.Finv.fsquare_times_in_place",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.Finv.fsquare_times"
] | [] | false | true | false | false | false | let fexp_223 x3 x44 x88 tmp =
| let h7 = ST.get () in
fsquare_times x88 x44 44ul;
fmul x88 x88 x44;
let h8 = ST.get () in
assert (feval h8 x88 == S.fmul (SI.fsquare_times (feval h7 x44) 44) (feval h7 x44));
fsquare_times tmp x88 88ul;
fmul tmp tmp x88;
let h9 = ST.get () in
assert (feval h9 tmp == S.fmul (SI.fsquare_times (feval h8 x88) 88) (feval h8 x88));
fsquare_times_in_place tmp 44ul;
fmul tmp tmp x44;
let h10 = ST.get () in
assert (feval h10 tmp == S.fmul (SI.fsquare_times (feval h9 tmp) 44) (feval h7 x44));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3;
let h11 = ST.get () in
assert (feval h11 tmp == S.fmul (SI.fsquare_times (feval h10 tmp) 3) (feval h7 x3)) | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.mul_mod | val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid | val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid | let mul_mod ctx x y xy = fmul xy x y | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 54,
"start_col": 0,
"start_line": 54
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | Hacl.Impl.Exponentiation.Definitions.lmul_st Lib.IntTypes.U64
5ul
0ul
Hacl.Impl.K256.Finv.mk_to_k256_prime_comm_monoid | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.__uint_to_t",
"Hacl.K256.Field.fmul",
"Prims.unit"
] | [] | false | false | false | false | false | let mul_mod ctx x y xy =
| fmul xy x y | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.refl | val refl (a: LSeq.lseq uint64 5 {linv a}) : GTot S.felem | val refl (a: LSeq.lseq uint64 5 {linv a}) : GTot S.felem | let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4]) | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 34,
"start_col": 0,
"start_line": 32
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4]) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | a: Lib.Sequence.lseq Lib.IntTypes.uint64 5 {Hacl.Impl.K256.Finv.linv a}
-> Prims.GTot Spec.K256.PointOps.felem | Prims.GTot | [
"sometrivial"
] | [] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Impl.K256.Finv.linv",
"Hacl.Spec.K256.Field52.Definitions.feval5",
"FStar.Pervasives.Native.Mktuple5",
"Lib.Sequence.op_String_Access",
"Spec.K256.PointOps.felem"
] | [] | false | false | false | false | false | let refl (a: LSeq.lseq uint64 5 {linv a}) : GTot S.felem =
| let open Lib.Sequence in feval5 (a.[ 0 ], a.[ 1 ], a.[ 2 ], a.[ 3 ], a.[ 4 ]) | false |
InsertionSort2.fst | InsertionSort2.insert'_sorted | val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k)) | val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k)) | let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 39,
"start_col": 0,
"start_line": 34
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 -> l: Prims.list a -> k: (_: a -> Prims.int)
-> FStar.Pervasives.Lemma (requires GenericSort.sorted l k)
(ensures GenericSort.sorted (InsertionSort2.insert' x l k) k) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"InsertionSort2.insert'_sorted",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec insert'_sorted #a x l k =
| match l with
| [] | [_] -> ()
| hd :: tl -> if k x <= k hd then () else insert'_sorted x tl k | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.fsquare_times | val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b)) | val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b)) | let fsquare_times out a b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 a) (v b);
BE.lexp_pow2 5ul 0ul mk_k256_prime_concrete_ops (null uint64) a b out | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 95,
"start_col": 0,
"start_line": 92
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x
inline_for_extraction noextract
let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
}
val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b))
[@CInline]
let fsquare_times_in_place out b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b
val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | out: Hacl.K256.Field.felem -> a: Hacl.K256.Field.felem -> b: Lib.IntTypes.size_t
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Lib.IntTypes.size_t",
"Hacl.Impl.Exponentiation.lexp_pow2",
"Lib.IntTypes.U64",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.Finv.mk_k256_prime_concrete_ops",
"Lib.Buffer.null",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Prims.unit",
"Spec.Exponentiation.exp_pow2_lemma",
"Spec.K256.PointOps.felem",
"Hacl.Spec.K256.Finv.mk_nat_mod_concrete_ops",
"Hacl.K256.Field.feval",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let fsquare_times out a b =
| let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 a) (v b);
BE.lexp_pow2 5ul 0ul mk_k256_prime_concrete_ops (null uint64) a b out | false |
InsertionSort2.fst | InsertionSort2.insertionsort' | val insertionsort': #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> Tot (list a) | val insertionsort': #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> Tot (list a) | let rec insertionsort' #a l k =
match l with
| []
| [_] -> l
| hd::tl -> insert' hd (insertionsort' tl k) k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 66,
"start_col": 0,
"start_line": 62
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k))
let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k
val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x]))
let rec insert'_permutation #a x l k =
match l with
| []
| [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_permutation x tl k | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 | l: Prims.list a -> k: (_: a -> Prims.int) -> Prims.list a | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"InsertionSort2.insert'",
"InsertionSort2.insertionsort'"
] | [
"recursion"
] | false | false | false | false | false | let rec insertionsort' #a l k =
| match l with
| [] | [_] -> l
| hd :: tl -> insert' hd (insertionsort' tl k) k | false |
InsertionSort2.fst | InsertionSort2.insert'_permutation | val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x])) | val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x])) | let rec insert'_permutation #a x l k =
match l with
| []
| [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_permutation x tl k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 59,
"start_col": 0,
"start_line": 53
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k))
let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k
val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 -> l: Prims.list a -> k: (_: a -> Prims.int)
-> FStar.Pervasives.Lemma (ensures GenericSort.permutation_2 (InsertionSort2.insert' x l k) l [x]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"InsertionSort2.insert'_permutation",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec insert'_permutation #a x l k =
| match l with
| [] | [_] -> ()
| hd :: tl -> if k x <= k hd then () else insert'_permutation x tl k | false |
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.x0 | val x0 : b: Prims.bool -> _: Prims.int -> Prims.PURE (Prims.int * Prims.int) | let x0 (b:bool) = reify (ifc b) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 24,
"start_col": 7,
"start_line": 24
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> _: Prims.int -> Prims.PURE (Prims.int * Prims.int) | Prims.PURE | [] | [] | [
"Prims.bool",
"FStar.DM4F.IntST.ifc",
"Prims.int",
"FStar.Pervasives.Native.tuple2",
"Prims.l_Forall"
] | [] | false | false | false | false | false | let x0 (b: bool) =
| reify (ifc b) | false |
|
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.x | val x : Prims.int * Prims.int | let x = reify (ifc b) s0 | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 22,
"start_col": 0,
"start_line": 22
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": 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.int | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.IntST.ifc",
"IfcReificationRegressionTest.b",
"Prims.int",
"IfcReificationRegressionTest.s0"
] | [] | false | false | false | true | false | let x =
| reify (ifc b) s0 | false |
|
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.sqr_mod | val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid | val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid | let sqr_mod ctx x xx = fsqr xx x | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 59,
"start_col": 0,
"start_line": 59
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | Hacl.Impl.Exponentiation.Definitions.lsqr_st Lib.IntTypes.U64
5ul
0ul
Hacl.Impl.K256.Finv.mk_to_k256_prime_comm_monoid | Prims.Tot | [
"total"
] | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.__uint_to_t",
"Hacl.K256.Field.fsqr",
"Prims.unit"
] | [] | false | false | false | false | false | let sqr_mod ctx x xx =
| fsqr xx x | false |
InsertionSort2.fst | InsertionSort2.insertionsort'_stable | val insertionsort'_stable: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures stable (insertionsort' l k) l k) | val insertionsort'_stable: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures stable (insertionsort' l k) l k) | let rec insertionsort'_stable #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_stable tl k;
insertionsort'_sorted tl k;
insert'_stable hd (insertionsort' tl k) k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 87,
"start_col": 0,
"start_line": 80
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k))
let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k
val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x]))
let rec insert'_permutation #a x l k =
match l with
| []
| [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_permutation x tl k
val insertionsort': #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insertionsort' #a l k =
match l with
| []
| [_] -> l
| hd::tl -> insert' hd (insertionsort' tl k) k
val insertionsort'_sorted: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(sorted (insertionsort' l k) k))
let rec insertionsort'_sorted #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_sorted tl k;
insert'_sorted hd (insertionsort' tl k) k
val insertionsort'_stable: #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 | l: Prims.list a -> k: (_: a -> Prims.int)
-> FStar.Pervasives.Lemma
(ensures GenericStability.stable (InsertionSort2.insertionsort' l k) l k) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"InsertionSort2.insert'_stable",
"InsertionSort2.insertionsort'",
"Prims.unit",
"InsertionSort2.insertionsort'_sorted",
"InsertionSort2.insertionsort'_stable"
] | [
"recursion"
] | false | false | true | false | false | let rec insertionsort'_stable #a l k =
| match l with
| [] | [_] -> ()
| hd :: tl ->
insertionsort'_stable tl k;
insertionsort'_sorted tl k;
insert'_stable hd (insertionsort' tl k) k | false |
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.x1 | val x1 : b: Prims.bool -> _: Prims.int -> Prims.int * Prims.int | let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 35,
"start_col": 0,
"start_line": 26
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> _: Prims.int -> Prims.int * Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.int",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.DM4F.IntST.decr",
"FStar.DM4F.IntST.get",
"FStar.DM4F.IntST.incr",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let x1 (b: bool) =
| match b with
| true ->
(fun s0 ->
let _, s = reify (incr ()) s0 in
let y, s = reify (get ()) s in
let _, s = reify (decr ()) s in
(y, s))
| _ ->
(fun s0 ->
let x, s = reify (get ()) s0 in
(fun s0 -> (x + 1, s0)) s) | false |
|
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.x2 | val x2 : b: Prims.bool -> _: Prims.int -> Prims.int * Prims.int | let x2 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 -> reify (get () + 1) s0) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 44,
"start_col": 0,
"start_line": 37
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b)
let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> _: Prims.int -> Prims.int * Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.int",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.DM4F.IntST.decr",
"FStar.DM4F.IntST.get",
"FStar.DM4F.IntST.incr",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let x2 (b: bool) =
| match b with
| true ->
(fun s0 ->
let _, s = reify (incr ()) s0 in
let y, s = reify (get ()) s in
let _, s = reify (decr ()) s in
(y, s))
| _ -> (fun s0 -> reify (get () + 1) s0) | false |
|
InsertionSort2.fst | InsertionSort2.insertionsort | val insertionsort: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Pure (list a)
(requires True)
(ensures (fun l' -> sorted l' k /\ stable l l' k /\ permutation l l')) | val insertionsort: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Pure (list a)
(requires True)
(ensures (fun l' -> sorted l' k /\ stable l l' k /\ permutation l l')) | let insertionsort #a l k =
insertionsort'_permutation l k;
insertionsort'_stable l k;
insertionsort'_sorted l k;
insertionsort' l k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 107,
"start_col": 0,
"start_line": 103
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k))
let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k
val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x]))
let rec insert'_permutation #a x l k =
match l with
| []
| [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_permutation x tl k
val insertionsort': #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insertionsort' #a l k =
match l with
| []
| [_] -> l
| hd::tl -> insert' hd (insertionsort' tl k) k
val insertionsort'_sorted: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(sorted (insertionsort' l k) k))
let rec insertionsort'_sorted #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_sorted tl k;
insert'_sorted hd (insertionsort' tl k) k
val insertionsort'_stable: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures stable (insertionsort' l k) l k)
let rec insertionsort'_stable #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_stable tl k;
insertionsort'_sorted tl k;
insert'_stable hd (insertionsort' tl k) k
val insertionsort'_permutation: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(permutation (insertionsort' l k) l))
let rec insertionsort'_permutation #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_permutation tl k;
insert'_permutation hd (insertionsort' tl k) k
val insertionsort: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Pure (list a)
(requires True) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 | l: Prims.list a -> k: (_: a -> Prims.int) -> Prims.Pure (Prims.list a) | Prims.Pure | [] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"InsertionSort2.insertionsort'",
"Prims.unit",
"InsertionSort2.insertionsort'_sorted",
"InsertionSort2.insertionsort'_stable",
"InsertionSort2.insertionsort'_permutation"
] | [] | false | false | false | false | false | let insertionsort #a l k =
| insertionsort'_permutation l k;
insertionsort'_stable l k;
insertionsort'_sorted l k;
insertionsort' l k | false |
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.x3 | val x3 : b: Prims.bool -> s0: Prims.int -> Prims.int * Prims.int | let x3 (b:bool) (s0:int) =
match b with
| true ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s)
| _ -> reify (get () + 1) s0 | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 53,
"start_col": 0,
"start_line": 46
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b)
let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s)
let x2 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 -> reify (get () + 1) s0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Prims.bool -> s0: Prims.int -> Prims.int * Prims.int | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.int",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.DM4F.IntST.decr",
"FStar.DM4F.IntST.get",
"FStar.DM4F.IntST.incr",
"Prims.op_Addition"
] | [] | false | false | false | true | false | let x3 (b: bool) (s0: int) =
| match b with
| true ->
let _, s = reify (incr ()) s0 in
let y, s = reify (get ()) s in
let _, s = reify (decr ()) s in
(y, s)
| _ -> reify (get () + 1) s0 | false |
|
InsertionSort2.fst | InsertionSort2.insertionsort'_sorted | val insertionsort'_sorted: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(sorted (insertionsort' l k) k)) | val insertionsort'_sorted: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(sorted (insertionsort' l k) k)) | let rec insertionsort'_sorted #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_sorted tl k;
insert'_sorted hd (insertionsort' tl k) k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 76,
"start_col": 0,
"start_line": 70
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k))
let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k
val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x]))
let rec insert'_permutation #a x l k =
match l with
| []
| [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_permutation x tl k
val insertionsort': #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insertionsort' #a l k =
match l with
| []
| [_] -> l
| hd::tl -> insert' hd (insertionsort' tl k) k
val insertionsort'_sorted: #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 | l: Prims.list a -> k: (_: a -> Prims.int)
-> FStar.Pervasives.Lemma (ensures GenericSort.sorted (InsertionSort2.insertionsort' l k) k) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"InsertionSort2.insert'_sorted",
"InsertionSort2.insertionsort'",
"Prims.unit",
"InsertionSort2.insertionsort'_sorted"
] | [
"recursion"
] | false | false | true | false | false | let rec insertionsort'_sorted #a l k =
| match l with
| [] | [_] -> ()
| hd :: tl ->
insertionsort'_sorted tl k;
insert'_sorted hd (insertionsort' tl k) k | false |
InsertionSort2.fst | InsertionSort2.insertionsort'_permutation | val insertionsort'_permutation: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(permutation (insertionsort' l k) l)) | val insertionsort'_permutation: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(permutation (insertionsort' l k) l)) | let rec insertionsort'_permutation #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_permutation tl k;
insert'_permutation hd (insertionsort' tl k) k | {
"file_name": "examples/algorithms/InsertionSort2.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 97,
"start_col": 0,
"start_line": 91
} | (*
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.
*)
(** This module implements a stable insertion sort. **)
module InsertionSort2
(** @author A Manning **)
open FStar.List.Tot
open GenericSort
open GenericStability
val insert': #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insert' #a x l k =
match l with
| [] -> [x]
| hd::tl ->
if k x <= k hd then x::l
else hd::(insert' x tl k)
val insert'_sorted: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (sorted (insert' x l k) k))
let rec insert'_sorted #a x l k =
match l with
| [] | [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_sorted x tl k
val insert'_stable: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma (requires (sorted l k))
(ensures (stable (insert' x l k) (x::l) k))
let rec insert'_stable #a x l k =
match l with
| [] -> ()
| hd::tl ->
if k x <= k hd then filter_eq_append [x] (insert' x tl k) k
else insert'_stable x tl k
val insert'_permutation: #a:eqtype -> x:a -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures (permutation_2 (insert' x l k) l [x]))
let rec insert'_permutation #a x l k =
match l with
| []
| [_] -> ()
| hd::tl ->
if k x <= k hd then ()
else insert'_permutation x tl k
val insertionsort': #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> Tot (list a)
let rec insertionsort' #a l k =
match l with
| []
| [_] -> l
| hd::tl -> insert' hd (insertionsort' tl k) k
val insertionsort'_sorted: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures(sorted (insertionsort' l k) k))
let rec insertionsort'_sorted #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_sorted tl k;
insert'_sorted hd (insertionsort' tl k) k
val insertionsort'_stable: #a:eqtype -> l:(list a) -> k:(a -> Tot int) ->
Lemma(ensures stable (insertionsort' l k) l k)
let rec insertionsort'_stable #a l k =
match l with
| []
| [_] -> ()
| hd::tl ->
insertionsort'_stable tl k;
insertionsort'_sorted tl k;
insert'_stable hd (insertionsort' tl k) k
val insertionsort'_permutation: #a:eqtype -> l:(list a) -> k:(a -> Tot int) -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"GenericStability.fst.checked",
"GenericSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort2.fst"
} | [
{
"abbrev": false,
"full_module": "GenericStability",
"short_module": null
},
{
"abbrev": false,
"full_module": "GenericSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": 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 | l: Prims.list a -> k: (_: a -> Prims.int)
-> FStar.Pervasives.Lemma (ensures GenericSort.permutation (InsertionSort2.insertionsort' l k) l) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.int",
"InsertionSort2.insert'_permutation",
"InsertionSort2.insertionsort'",
"Prims.unit",
"InsertionSort2.insertionsort'_permutation"
] | [
"recursion"
] | false | false | true | false | false | let rec insertionsort'_permutation #a l k =
| match l with
| [] | [_] -> ()
| hd :: tl ->
insertionsort'_permutation tl k;
insert'_permutation hd (insertionsort' tl k) k | false |
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.bidule2 | val bidule2 : Prims.unit | let bidule2 = assert (forall s0. x2 true s0 = x2 false s0) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 57,
"start_col": 0,
"start_line": 57
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b)
let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s)
let x2 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 -> reify (get () + 1) s0)
let x3 (b:bool) (s0:int) =
match b with
| true ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s)
| _ -> reify (get () + 1) s0
let bidule0 = assert (forall s0. x0 true s0 = x0 false s0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims._assert",
"Prims.l_Forall",
"Prims.int",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Pervasives.Native.tuple2",
"IfcReificationRegressionTest.x2"
] | [] | false | false | false | true | false | let bidule2 =
| assert (forall s0. x2 true s0 = x2 false s0) | false |
|
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.bidule1 | val bidule1 : Prims.unit | let bidule1 = assert (forall s0. x1 true s0 = x1 false s0) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 56,
"start_col": 0,
"start_line": 56
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b)
let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s)
let x2 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 -> reify (get () + 1) s0)
let x3 (b:bool) (s0:int) =
match b with
| true ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s)
| _ -> reify (get () + 1) s0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims._assert",
"Prims.l_Forall",
"Prims.int",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Pervasives.Native.tuple2",
"IfcReificationRegressionTest.x1"
] | [] | false | false | false | true | false | let bidule1 =
| assert (forall s0. x1 true s0 = x1 false s0) | false |
|
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.fexp_44 | val fexp_44 (x2 x3 x22 x44 tmp:felem) : Stack unit
(requires fun h ->
live h x2 /\ live h x3 /\ live h x22 /\ live h x44 /\ live h tmp /\
disjoint x2 x3 /\ disjoint x2 x22 /\ disjoint x2 x44 /\
disjoint x2 tmp /\ disjoint x3 x22 /\ disjoint x3 x44 /\
disjoint x3 tmp /\ disjoint x22 x44 /\ disjoint x22 tmp /\
disjoint x44 tmp /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h x3)
(ensures fun h0 _ h1 -> modifies (loc x22 |+| loc x44 |+| loc tmp) h0 h1 /\
(let _x2 = feval h0 x2 in
let _x3 = feval h0 x3 in
let _x6 = S.fmul (SI.fsquare_times _x3 3) _x3 in
let _x9 = S.fmul (SI.fsquare_times _x6 3) _x3 in
let _x11 = S.fmul (SI.fsquare_times _x9 2) _x2 in
let _x22 = S.fmul (SI.fsquare_times _x11 11) _x11 in
let _x44 = S.fmul (SI.fsquare_times _x22 22) _x22 in
feval h1 tmp == _x11 /\ feval h1 x22 == _x22 /\ feval h1 x44 == _x44 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x22 /\ inv_lazy_reduced2 h1 x44)) | val fexp_44 (x2 x3 x22 x44 tmp:felem) : Stack unit
(requires fun h ->
live h x2 /\ live h x3 /\ live h x22 /\ live h x44 /\ live h tmp /\
disjoint x2 x3 /\ disjoint x2 x22 /\ disjoint x2 x44 /\
disjoint x2 tmp /\ disjoint x3 x22 /\ disjoint x3 x44 /\
disjoint x3 tmp /\ disjoint x22 x44 /\ disjoint x22 tmp /\
disjoint x44 tmp /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h x3)
(ensures fun h0 _ h1 -> modifies (loc x22 |+| loc x44 |+| loc tmp) h0 h1 /\
(let _x2 = feval h0 x2 in
let _x3 = feval h0 x3 in
let _x6 = S.fmul (SI.fsquare_times _x3 3) _x3 in
let _x9 = S.fmul (SI.fsquare_times _x6 3) _x3 in
let _x11 = S.fmul (SI.fsquare_times _x9 2) _x2 in
let _x22 = S.fmul (SI.fsquare_times _x11 11) _x11 in
let _x44 = S.fmul (SI.fsquare_times _x22 22) _x22 in
feval h1 tmp == _x11 /\ feval h1 x22 == _x22 /\ feval h1 x44 == _x44 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x22 /\ inv_lazy_reduced2 h1 x44)) | let fexp_44 x2 x3 x22 x44 tmp =
let h2 = ST.get () in
fsquare_times tmp x3 3ul;
fmul tmp tmp x3; // tmp = x6 = S.fmul (fsquare_times x3 3) x3
let h3 = ST.get () in
assert (feval h3 tmp == S.fmul (SI.fsquare_times (feval h2 x3) 3) (feval h2 x3));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x9 = S.fmul (fsquare_times x6 3) x3
let h4 = ST.get () in
assert (feval h4 tmp == S.fmul (SI.fsquare_times (feval h3 tmp) 3) (feval h2 x3));
fsquare_times_in_place tmp 2ul;
fmul tmp tmp x2; // tmp = x11 = S.fmul (fsquare_times x9 2) x2
let h5 = ST.get () in
assert (feval h5 tmp == S.fmul (SI.fsquare_times (feval h4 tmp) 2) (feval h2 x2));
fsquare_times x22 tmp 11ul;
fmul x22 x22 tmp; // x22 = S.fmul (fsquare_times x11 11) x11
let h6 = ST.get () in
assert (feval h6 x22 == S.fmul (SI.fsquare_times (feval h5 tmp) 11) (feval h5 tmp));
fsquare_times x44 x22 22ul;
fmul x44 x44 x22; // x44 = S.fmul (fsquare_times x22 22) x22
let h7 = ST.get () in
assert (feval h7 x44 == S.fmul (SI.fsquare_times (feval h6 x22) 22) (feval h6 x22)) | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 85,
"end_line": 142,
"start_col": 0,
"start_line": 117
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x
inline_for_extraction noextract
let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
}
val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b))
[@CInline]
let fsquare_times_in_place out b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b
val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b))
[@CInline]
let fsquare_times out a b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 a) (v b);
BE.lexp_pow2 5ul 0ul mk_k256_prime_concrete_ops (null uint64) a b out
inline_for_extraction noextract
val fexp_44 (x2 x3 x22 x44 tmp:felem) : Stack unit
(requires fun h ->
live h x2 /\ live h x3 /\ live h x22 /\ live h x44 /\ live h tmp /\
disjoint x2 x3 /\ disjoint x2 x22 /\ disjoint x2 x44 /\
disjoint x2 tmp /\ disjoint x3 x22 /\ disjoint x3 x44 /\
disjoint x3 tmp /\ disjoint x22 x44 /\ disjoint x22 tmp /\
disjoint x44 tmp /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h x3)
(ensures fun h0 _ h1 -> modifies (loc x22 |+| loc x44 |+| loc tmp) h0 h1 /\
(let _x2 = feval h0 x2 in
let _x3 = feval h0 x3 in
let _x6 = S.fmul (SI.fsquare_times _x3 3) _x3 in
let _x9 = S.fmul (SI.fsquare_times _x6 3) _x3 in
let _x11 = S.fmul (SI.fsquare_times _x9 2) _x2 in
let _x22 = S.fmul (SI.fsquare_times _x11 11) _x11 in
let _x44 = S.fmul (SI.fsquare_times _x22 22) _x22 in
feval h1 tmp == _x11 /\ feval h1 x22 == _x22 /\ feval h1 x44 == _x44 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x22 /\ inv_lazy_reduced2 h1 x44)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 |
x2: Hacl.K256.Field.felem ->
x3: Hacl.K256.Field.felem ->
x22: Hacl.K256.Field.felem ->
x44: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Prims._assert",
"Prims.eq2",
"Spec.K256.PointOps.felem",
"Hacl.K256.Field.feval",
"Spec.K256.PointOps.fmul",
"Hacl.Spec.K256.Finv.fsquare_times",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.Finv.fsquare_times",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.Finv.fsquare_times_in_place"
] | [] | false | true | false | false | false | let fexp_44 x2 x3 x22 x44 tmp =
| let h2 = ST.get () in
fsquare_times tmp x3 3ul;
fmul tmp tmp x3;
let h3 = ST.get () in
assert (feval h3 tmp == S.fmul (SI.fsquare_times (feval h2 x3) 3) (feval h2 x3));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3;
let h4 = ST.get () in
assert (feval h4 tmp == S.fmul (SI.fsquare_times (feval h3 tmp) 3) (feval h2 x3));
fsquare_times_in_place tmp 2ul;
fmul tmp tmp x2;
let h5 = ST.get () in
assert (feval h5 tmp == S.fmul (SI.fsquare_times (feval h4 tmp) 2) (feval h2 x2));
fsquare_times x22 tmp 11ul;
fmul x22 x22 tmp;
let h6 = ST.get () in
assert (feval h6 x22 == S.fmul (SI.fsquare_times (feval h5 tmp) 11) (feval h5 tmp));
fsquare_times x44 x22 22ul;
fmul x44 x44 x22;
let h7 = ST.get () in
assert (feval h7 x44 == S.fmul (SI.fsquare_times (feval h6 x22) 22) (feval h6 x22)) | false |
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.bidule0 | val bidule0 : Prims.unit | let bidule0 = assert (forall s0. x0 true s0 = x0 false s0) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 55,
"start_col": 0,
"start_line": 55
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b)
let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s)
let x2 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 -> reify (get () + 1) s0)
let x3 (b:bool) (s0:int) =
match b with
| true ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s)
| _ -> reify (get () + 1) s0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims._assert",
"Prims.l_Forall",
"Prims.int",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Pervasives.Native.tuple2",
"IfcReificationRegressionTest.x0"
] | [] | false | false | false | true | false | let bidule0 =
| assert (forall s0. x0 true s0 = x0 false s0) | false |
|
IfcReificationRegressionTest.fst | IfcReificationRegressionTest.bidule3 | val bidule3 : Prims.unit | let bidule3 = assert (forall s0. x3 true s0 = x3 false s0) | {
"file_name": "examples/rel/IfcReificationRegressionTest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 58,
"start_col": 0,
"start_line": 58
} | (*
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 IfcReificationRegressionTest
open FStar.DM4F.IntST
assume val b : bool
assume val s0 : int
let x = reify (ifc b) s0
unfold let x0 (b:bool) = reify (ifc b)
let x1 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 ->
let (x,s) = reify (get ()) s0 in
(fun s0 -> (x+1, s0)) s)
let x2 (b:bool) =
match b with
| true -> (fun s0 ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s))
| _ -> (fun s0 -> reify (get () + 1) s0)
let x3 (b:bool) (s0:int) =
match b with
| true ->
let (_,s) = reify (incr ()) s0 in
let (y,s) = reify (get ()) s in
let (_,s) = reify (decr ()) s in
(y,s)
| _ -> reify (get () + 1) s0
let bidule0 = assert (forall s0. x0 true s0 = x0 false s0)
let bidule1 = assert (forall s0. x1 true s0 = x1 false s0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntST.fst.checked"
],
"interface_file": false,
"source_file": "IfcReificationRegressionTest.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims._assert",
"Prims.l_Forall",
"Prims.int",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Pervasives.Native.tuple2",
"IfcReificationRegressionTest.x3"
] | [] | false | false | false | true | false | let bidule3 =
| assert (forall s0. x3 true s0 = x3 false s0) | false |
|
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.fsqrt | val fsqrt (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.fsqrt (feval h0 f) /\
inv_lazy_reduced2 h1 out) | val fsqrt (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.fsqrt (feval h0 f) /\
inv_lazy_reduced2 h1 out) | let fsqrt out f =
let h0 = ST.get () in
SI.fsqrt_is_fsqrt_lemma (feval h0 f);
push_frame ();
let x2 = create_felem () in
fexp_223_23 out x2 f;
let h1 = ST.get () in
fsquare_times_in_place out 6ul;
fmul out out x2; // out = r = S.fmul (fsquare_times r 6) x2
let h2 = ST.get () in
assert (feval h2 out == S.fmul (SI.fsquare_times (feval h1 out) 6) (feval h1 x2));
fsquare_times_in_place out 2ul;
let h3 = ST.get () in
assert (feval h3 out == SI.fsquare_times (feval h2 out) 2);
assert (feval h3 out == S.fsqrt (feval h0 f) /\ inv_lazy_reduced2 h3 out);
pop_frame () | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 288,
"start_col": 0,
"start_line": 271
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x
inline_for_extraction noextract
let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
}
val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b))
[@CInline]
let fsquare_times_in_place out b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b
val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b))
[@CInline]
let fsquare_times out a b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 a) (v b);
BE.lexp_pow2 5ul 0ul mk_k256_prime_concrete_ops (null uint64) a b out
inline_for_extraction noextract
val fexp_44 (x2 x3 x22 x44 tmp:felem) : Stack unit
(requires fun h ->
live h x2 /\ live h x3 /\ live h x22 /\ live h x44 /\ live h tmp /\
disjoint x2 x3 /\ disjoint x2 x22 /\ disjoint x2 x44 /\
disjoint x2 tmp /\ disjoint x3 x22 /\ disjoint x3 x44 /\
disjoint x3 tmp /\ disjoint x22 x44 /\ disjoint x22 tmp /\
disjoint x44 tmp /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h x3)
(ensures fun h0 _ h1 -> modifies (loc x22 |+| loc x44 |+| loc tmp) h0 h1 /\
(let _x2 = feval h0 x2 in
let _x3 = feval h0 x3 in
let _x6 = S.fmul (SI.fsquare_times _x3 3) _x3 in
let _x9 = S.fmul (SI.fsquare_times _x6 3) _x3 in
let _x11 = S.fmul (SI.fsquare_times _x9 2) _x2 in
let _x22 = S.fmul (SI.fsquare_times _x11 11) _x11 in
let _x44 = S.fmul (SI.fsquare_times _x22 22) _x22 in
feval h1 tmp == _x11 /\ feval h1 x22 == _x22 /\ feval h1 x44 == _x44 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x22 /\ inv_lazy_reduced2 h1 x44))
let fexp_44 x2 x3 x22 x44 tmp =
let h2 = ST.get () in
fsquare_times tmp x3 3ul;
fmul tmp tmp x3; // tmp = x6 = S.fmul (fsquare_times x3 3) x3
let h3 = ST.get () in
assert (feval h3 tmp == S.fmul (SI.fsquare_times (feval h2 x3) 3) (feval h2 x3));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x9 = S.fmul (fsquare_times x6 3) x3
let h4 = ST.get () in
assert (feval h4 tmp == S.fmul (SI.fsquare_times (feval h3 tmp) 3) (feval h2 x3));
fsquare_times_in_place tmp 2ul;
fmul tmp tmp x2; // tmp = x11 = S.fmul (fsquare_times x9 2) x2
let h5 = ST.get () in
assert (feval h5 tmp == S.fmul (SI.fsquare_times (feval h4 tmp) 2) (feval h2 x2));
fsquare_times x22 tmp 11ul;
fmul x22 x22 tmp; // x22 = S.fmul (fsquare_times x11 11) x11
let h6 = ST.get () in
assert (feval h6 x22 == S.fmul (SI.fsquare_times (feval h5 tmp) 11) (feval h5 tmp));
fsquare_times x44 x22 22ul;
fmul x44 x44 x22; // x44 = S.fmul (fsquare_times x22 22) x22
let h7 = ST.get () in
assert (feval h7 x44 == S.fmul (SI.fsquare_times (feval h6 x22) 22) (feval h6 x22))
inline_for_extraction noextract
val fexp_223 (x3 x44 x88 tmp:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h x44 /\ live h x88 /\ live h tmp /\
disjoint x3 x44 /\ disjoint x3 x88 /\ disjoint x3 tmp /\
disjoint x44 x88 /\ disjoint x44 tmp /\ disjoint x88 tmp /\
inv_lazy_reduced2 h x3 /\ inv_lazy_reduced2 h x44)
(ensures fun h0 _ h1 -> modifies (loc x88 |+| loc tmp) h0 h1 /\
(let _x3 = feval h0 x3 in
let _x44 = feval h0 x44 in
let _x88 = S.fmul (SI.fsquare_times _x44 44) _x44 in
let _x176 = S.fmul (SI.fsquare_times _x88 88) _x88 in
let _x220 = S.fmul (SI.fsquare_times _x176 44) _x44 in
let _x223 = S.fmul (SI.fsquare_times _x220 3) _x3 in
feval h1 tmp == _x223 /\ feval h1 x88 == _x88 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x88))
let fexp_223 x3 x44 x88 tmp =
let h7 = ST.get () in
fsquare_times x88 x44 44ul;
fmul x88 x88 x44; // x88 = S.fmul (fsquare_times x44 44) x44
let h8 = ST.get () in
assert (feval h8 x88 == S.fmul (SI.fsquare_times (feval h7 x44) 44) (feval h7 x44));
fsquare_times tmp x88 88ul;
fmul tmp tmp x88; // tmp = x176 = S.fmul (fsquare_times x88 88) x88
let h9 = ST.get () in
assert (feval h9 tmp == S.fmul (SI.fsquare_times (feval h8 x88) 88) (feval h8 x88));
fsquare_times_in_place tmp 44ul;
fmul tmp tmp x44; // tmp = x220 = S.fmul (fsquare_times x176 44) x44
let h10 = ST.get () in
assert (feval h10 tmp == S.fmul (SI.fsquare_times (feval h9 tmp) 44) (feval h7 x44));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x223 = S.fmul (fsquare_times x220 3) x3
let h11 = ST.get () in
assert (feval h11 tmp == S.fmul (SI.fsquare_times (feval h10 tmp) 3) (feval h7 x3))
val fexp_223_23 (out x2 f:felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ live h x2 /\
disjoint out f /\ disjoint out x2 /\ disjoint f x2 /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc x2) h0 h1 /\
inv_lazy_reduced2 h1 out /\ inv_lazy_reduced2 h1 x2 /\
(feval h1 out, feval h1 x2) == SI.fexp_223_23 (feval h0 f))
[@CInline]
let fexp_223_23 out x2 f =
push_frame ();
let x3 = create_felem () in
let x22 = create_felem () in
let x44 = create_felem () in
let x88 = create_felem () in
let h0 = ST.get () in
fsquare_times x2 f 1ul;
fmul x2 x2 f; // x2 = S.fmul (fsquare_times f 1) f
let h1 = ST.get () in
assert (feval h1 x2 == S.fmul (SI.fsquare_times (feval h0 f) 1) (feval h0 f));
assert (modifies (loc x2) h0 h1);
fsquare_times x3 x2 1ul;
fmul x3 x3 f; // x3 = S.fmul (fsquare_times x2 1) f
let h2 = ST.get () in
assert (feval h2 x3 == S.fmul (SI.fsquare_times (feval h1 x2) 1) (feval h0 f));
assert (modifies (loc x3) h1 h2);
fexp_44 x2 x3 x22 x44 out;
fexp_223 x3 x44 x88 out;
let h3 = ST.get () in
assert (modifies (loc x22 |+| loc x44 |+| loc x88 |+| loc out) h2 h3);
fsquare_times_in_place out 23ul;
fmul out out x22; // out = r = S.fmul (fsquare_times x223 23) x22
let h4 = ST.get () in
assert (feval h4 out == S.fmul (SI.fsquare_times (feval h3 out) 23) (feval h3 x22));
pop_frame ()
val finv (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.finv (feval h0 f) /\
inv_lazy_reduced2 h1 out)
[@CInline]
let finv out f =
let h0 = ST.get () in
SI.finv_is_finv_lemma (feval h0 f);
push_frame ();
let x2 = create_felem () in
fexp_223_23 out x2 f;
let h1 = ST.get () in
fsquare_times_in_place out 5ul;
fmul out out f; // out = r = S.fmul (fsquare_times r 5) f
let h2 = ST.get () in
assert (feval h2 out == S.fmul (SI.fsquare_times (feval h1 out) 5) (feval h0 f));
fsquare_times_in_place out 3ul;
fmul out out x2; // out = r = S.fmul (fsquare_times r 3) x2
let h3 = ST.get () in
assert (feval h3 out == S.fmul (SI.fsquare_times (feval h2 out) 3) (feval h1 x2));
fsquare_times_in_place out 2ul;
fmul out out f; // out = r = S.fmul (fsquare_times r 2) f
let h4 = ST.get () in
assert (feval h4 out == S.fmul (SI.fsquare_times (feval h3 out) 2) (feval h0 f));
assert (feval h4 out == S.finv (feval h0 f) /\ inv_lazy_reduced2 h4 out);
pop_frame ()
val fsqrt (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.fsqrt (feval h0 f) /\
inv_lazy_reduced2 h1 out) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | out: Hacl.K256.Field.felem -> f: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Prims._assert",
"Prims.l_and",
"Prims.eq2",
"Spec.K256.PointOps.felem",
"Hacl.K256.Field.feval",
"Spec.K256.PointOps.fsqrt",
"Hacl.K256.Field.inv_lazy_reduced2",
"Hacl.Spec.K256.Finv.fsquare_times",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.K256.Finv.fsquare_times_in_place",
"FStar.UInt32.__uint_to_t",
"Spec.K256.PointOps.fmul",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.Finv.fexp_223_23",
"Hacl.K256.Field.create_felem",
"FStar.HyperStack.ST.push_frame",
"Hacl.Spec.K256.Finv.fsqrt_is_fsqrt_lemma"
] | [] | false | true | false | false | false | let fsqrt out f =
| let h0 = ST.get () in
SI.fsqrt_is_fsqrt_lemma (feval h0 f);
push_frame ();
let x2 = create_felem () in
fexp_223_23 out x2 f;
let h1 = ST.get () in
fsquare_times_in_place out 6ul;
fmul out out x2;
let h2 = ST.get () in
assert (feval h2 out == S.fmul (SI.fsquare_times (feval h1 out) 6) (feval h1 x2));
fsquare_times_in_place out 2ul;
let h3 = ST.get () in
assert (feval h3 out == SI.fsquare_times (feval h2 out) 2);
assert (feval h3 out == S.fsqrt (feval h0 f) /\ inv_lazy_reduced2 h3 out);
pop_frame () | false |
Hacl.Impl.K256.PointAdd.fst | Hacl.Impl.K256.PointAdd.ab_plus_cd | val ab_plus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (3,3,3,3,6) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fadd
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c) | val ab_plus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (3,3,3,3,6) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fadd
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c) | let ab_plus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c);
fadd c tmp c;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (2,2,2,2,4));
fnormalize_weak c c;
BL.normalize_weak5_lemma (2,2,2,2,4) (as_felem5 h2 c) | {
"file_name": "code/k256/Hacl.Impl.K256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 92,
"start_col": 0,
"start_line": 81
} | module Hacl.Impl.K256.PointAdd
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 BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10))
let point_add_xy_pairs x1 y1 x2 y2 xx yy tmp xy_pairs =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x1) (as_felem5 h0 y1);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x2) (as_felem5 h0 y2);
fadd xy_pairs x1 y1;
fadd tmp x2 y2;
let h1 = ST.get () in
assert (felem_fits5 (as_felem5 h1 xy_pairs) (2,2,2,2,4));
assert (felem_fits5 (as_felem5 h1 tmp) (2,2,2,2,4));
fmul xy_pairs xy_pairs tmp;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 xy_pairs) (1,1,1,1,2));
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h2 xx) (as_felem5 h2 yy);
fadd tmp xx yy;
let h3 = ST.get () in
assert (felem_fits5 (as_felem5 h3 tmp) (2,2,2,2,4));
fsub xy_pairs xy_pairs tmp (u64 4);
let h4 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (2,2,2,2,4) (as_felem5 h3 xy_pairs) (as_felem5 h3 tmp) (u64 4);
assert (felem_fits5 (as_felem5 h4 xy_pairs) (9,9,9,9,10))
inline_for_extraction noextract
val ab_plus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (3,3,3,3,6) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fadd
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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.PointAdd.fst"
} | [
{
"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": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Hacl.K256.Field.felem ->
b: Hacl.K256.Field.felem ->
c: Hacl.K256.Field.felem ->
d: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Hacl.Spec.K256.Field52.Lemmas.normalize_weak5_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"Prims.unit",
"Hacl.K256.Field.fnormalize_weak",
"Prims._assert",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fadd",
"Hacl.Spec.K256.Field52.Lemmas.fadd5_lemma",
"Hacl.K256.Field.inv_lazy_reduced2",
"Hacl.K256.Field.fmul"
] | [] | false | true | false | false | false | let ab_plus_cd a b c d tmp =
| fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h1 tmp) (as_felem5 h1 c);
fadd c tmp c;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (2, 2, 2, 2, 4));
fnormalize_weak c c;
BL.normalize_weak5_lemma (2, 2, 2, 2, 4) (as_felem5 h2 c) | false |
Hacl.Impl.K256.PointAdd.fst | Hacl.Impl.K256.PointAdd.ab_minus_cd | val ab_minus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (1,1,1,1,2) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fsub
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c) | val ab_minus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (1,1,1,1,2) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fsub
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c) | let ab_minus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c) (u64 2);
fsub c tmp c (u64 2);
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (5,5,5,5,6));
fnormalize_weak c c;
BL.normalize_weak5_lemma (5,5,5,5,6) (as_felem5 h2 c) | {
"file_name": "code/k256/Hacl.Impl.K256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 124,
"start_col": 0,
"start_line": 113
} | module Hacl.Impl.K256.PointAdd
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 BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10))
let point_add_xy_pairs x1 y1 x2 y2 xx yy tmp xy_pairs =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x1) (as_felem5 h0 y1);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x2) (as_felem5 h0 y2);
fadd xy_pairs x1 y1;
fadd tmp x2 y2;
let h1 = ST.get () in
assert (felem_fits5 (as_felem5 h1 xy_pairs) (2,2,2,2,4));
assert (felem_fits5 (as_felem5 h1 tmp) (2,2,2,2,4));
fmul xy_pairs xy_pairs tmp;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 xy_pairs) (1,1,1,1,2));
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h2 xx) (as_felem5 h2 yy);
fadd tmp xx yy;
let h3 = ST.get () in
assert (felem_fits5 (as_felem5 h3 tmp) (2,2,2,2,4));
fsub xy_pairs xy_pairs tmp (u64 4);
let h4 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (2,2,2,2,4) (as_felem5 h3 xy_pairs) (as_felem5 h3 tmp) (u64 4);
assert (felem_fits5 (as_felem5 h4 xy_pairs) (9,9,9,9,10))
inline_for_extraction noextract
val ab_plus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (3,3,3,3,6) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fadd
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c)
let ab_plus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c);
fadd c tmp c;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (2,2,2,2,4));
fnormalize_weak c c;
BL.normalize_weak5_lemma (2,2,2,2,4) (as_felem5 h2 c)
inline_for_extraction noextract
val ab_minus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (1,1,1,1,2) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fsub
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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.PointAdd.fst"
} | [
{
"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": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Hacl.K256.Field.felem ->
b: Hacl.K256.Field.felem ->
c: Hacl.K256.Field.felem ->
d: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Hacl.Spec.K256.Field52.Lemmas.normalize_weak5_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"Prims.unit",
"Hacl.K256.Field.fnormalize_weak",
"Prims._assert",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fsub",
"Lib.IntTypes.u64",
"Hacl.Spec.K256.Field52.Lemmas.fsub5_lemma",
"Hacl.K256.Field.inv_lazy_reduced2",
"Hacl.K256.Field.fmul"
] | [] | false | true | false | false | false | let ab_minus_cd a b c d tmp =
| fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fsub5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h1 tmp) (as_felem5 h1 c) (u64 2);
fsub c tmp c (u64 2);
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (5, 5, 5, 5, 6));
fnormalize_weak c c;
BL.normalize_weak5_lemma (5, 5, 5, 5, 6) (as_felem5 h2 c) | false |
Hacl.Impl.K256.Finv.fst | Hacl.Impl.K256.Finv.finv | val finv (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.finv (feval h0 f) /\
inv_lazy_reduced2 h1 out) | val finv (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.finv (feval h0 f) /\
inv_lazy_reduced2 h1 out) | let finv out f =
let h0 = ST.get () in
SI.finv_is_finv_lemma (feval h0 f);
push_frame ();
let x2 = create_felem () in
fexp_223_23 out x2 f;
let h1 = ST.get () in
fsquare_times_in_place out 5ul;
fmul out out f; // out = r = S.fmul (fsquare_times r 5) f
let h2 = ST.get () in
assert (feval h2 out == S.fmul (SI.fsquare_times (feval h1 out) 5) (feval h0 f));
fsquare_times_in_place out 3ul;
fmul out out x2; // out = r = S.fmul (fsquare_times r 3) x2
let h3 = ST.get () in
assert (feval h3 out == S.fmul (SI.fsquare_times (feval h2 out) 3) (feval h1 x2));
fsquare_times_in_place out 2ul;
fmul out out f; // out = r = S.fmul (fsquare_times r 2) f
let h4 = ST.get () in
assert (feval h4 out == S.fmul (SI.fsquare_times (feval h3 out) 2) (feval h0 f));
assert (feval h4 out == S.finv (feval h0 f) /\ inv_lazy_reduced2 h4 out);
pop_frame () | {
"file_name": "code/k256/Hacl.Impl.K256.Finv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 259,
"start_col": 0,
"start_line": 236
} | module Hacl.Impl.K256.Finv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.K256.Field
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module S = Spec.K256
module SI = Hacl.Spec.K256.Finv
module SE = Spec.Exponentiation
module BE = Hacl.Impl.Exponentiation
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
unfold
let linv_ctx (a:LSeq.lseq uint64 0) : Type0 = True
unfold
let linv (a:LSeq.lseq uint64 5) : Type0 =
let open Lib.Sequence in
inv_lazy_reduced2_5 (a.[0],a.[1],a.[2],a.[3],a.[4])
unfold
let refl (a:LSeq.lseq uint64 5{linv a}) : GTot S.felem =
let open Lib.Sequence in
feval5 (a.[0],a.[1],a.[2],a.[3],a.[4])
inline_for_extraction noextract
let mk_to_k256_prime_comm_monoid : BE.to_comm_monoid U64 5ul 0ul = {
BE.a_spec = S.felem;
BE.comm_monoid = SI.nat_mod_comm_monoid;
BE.linv_ctx = linv_ctx;
BE.linv = linv;
BE.refl = refl;
}
inline_for_extraction noextract
val one_mod : BE.lone_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let one_mod ctx one = make_u52_5 one (u64 1, u64 0, u64 0, u64 0, u64 0)
inline_for_extraction noextract
val mul_mod : BE.lmul_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let mul_mod ctx x y xy = fmul xy x y
inline_for_extraction noextract
val sqr_mod : BE.lsqr_st U64 5ul 0ul mk_to_k256_prime_comm_monoid
let sqr_mod ctx x xx = fsqr xx x
inline_for_extraction noextract
let mk_k256_prime_concrete_ops : BE.concrete_ops U64 5ul 0ul = {
BE.to = mk_to_k256_prime_comm_monoid;
BE.lone = one_mod;
BE.lmul = mul_mod;
BE.lsqr = sqr_mod;
}
val fsquare_times_in_place (out:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ inv_lazy_reduced2 h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 out) (v b))
[@CInline]
let fsquare_times_in_place out b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 out) (v b);
BE.lexp_pow2_in_place 5ul 0ul mk_k256_prime_concrete_ops (null uint64) out b
val fsquare_times (out a:felem) (b:size_t) : Stack unit
(requires fun h ->
live h out /\ live h a /\ disjoint out a /\
inv_lazy_reduced2 h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ inv_lazy_reduced2 h1 out /\
feval h1 out == SI.fsquare_times (feval h0 a) (v b))
[@CInline]
let fsquare_times out a b =
let h0 = ST.get () in
SE.exp_pow2_lemma SI.mk_nat_mod_concrete_ops (feval h0 a) (v b);
BE.lexp_pow2 5ul 0ul mk_k256_prime_concrete_ops (null uint64) a b out
inline_for_extraction noextract
val fexp_44 (x2 x3 x22 x44 tmp:felem) : Stack unit
(requires fun h ->
live h x2 /\ live h x3 /\ live h x22 /\ live h x44 /\ live h tmp /\
disjoint x2 x3 /\ disjoint x2 x22 /\ disjoint x2 x44 /\
disjoint x2 tmp /\ disjoint x3 x22 /\ disjoint x3 x44 /\
disjoint x3 tmp /\ disjoint x22 x44 /\ disjoint x22 tmp /\
disjoint x44 tmp /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h x3)
(ensures fun h0 _ h1 -> modifies (loc x22 |+| loc x44 |+| loc tmp) h0 h1 /\
(let _x2 = feval h0 x2 in
let _x3 = feval h0 x3 in
let _x6 = S.fmul (SI.fsquare_times _x3 3) _x3 in
let _x9 = S.fmul (SI.fsquare_times _x6 3) _x3 in
let _x11 = S.fmul (SI.fsquare_times _x9 2) _x2 in
let _x22 = S.fmul (SI.fsquare_times _x11 11) _x11 in
let _x44 = S.fmul (SI.fsquare_times _x22 22) _x22 in
feval h1 tmp == _x11 /\ feval h1 x22 == _x22 /\ feval h1 x44 == _x44 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x22 /\ inv_lazy_reduced2 h1 x44))
let fexp_44 x2 x3 x22 x44 tmp =
let h2 = ST.get () in
fsquare_times tmp x3 3ul;
fmul tmp tmp x3; // tmp = x6 = S.fmul (fsquare_times x3 3) x3
let h3 = ST.get () in
assert (feval h3 tmp == S.fmul (SI.fsquare_times (feval h2 x3) 3) (feval h2 x3));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x9 = S.fmul (fsquare_times x6 3) x3
let h4 = ST.get () in
assert (feval h4 tmp == S.fmul (SI.fsquare_times (feval h3 tmp) 3) (feval h2 x3));
fsquare_times_in_place tmp 2ul;
fmul tmp tmp x2; // tmp = x11 = S.fmul (fsquare_times x9 2) x2
let h5 = ST.get () in
assert (feval h5 tmp == S.fmul (SI.fsquare_times (feval h4 tmp) 2) (feval h2 x2));
fsquare_times x22 tmp 11ul;
fmul x22 x22 tmp; // x22 = S.fmul (fsquare_times x11 11) x11
let h6 = ST.get () in
assert (feval h6 x22 == S.fmul (SI.fsquare_times (feval h5 tmp) 11) (feval h5 tmp));
fsquare_times x44 x22 22ul;
fmul x44 x44 x22; // x44 = S.fmul (fsquare_times x22 22) x22
let h7 = ST.get () in
assert (feval h7 x44 == S.fmul (SI.fsquare_times (feval h6 x22) 22) (feval h6 x22))
inline_for_extraction noextract
val fexp_223 (x3 x44 x88 tmp:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h x44 /\ live h x88 /\ live h tmp /\
disjoint x3 x44 /\ disjoint x3 x88 /\ disjoint x3 tmp /\
disjoint x44 x88 /\ disjoint x44 tmp /\ disjoint x88 tmp /\
inv_lazy_reduced2 h x3 /\ inv_lazy_reduced2 h x44)
(ensures fun h0 _ h1 -> modifies (loc x88 |+| loc tmp) h0 h1 /\
(let _x3 = feval h0 x3 in
let _x44 = feval h0 x44 in
let _x88 = S.fmul (SI.fsquare_times _x44 44) _x44 in
let _x176 = S.fmul (SI.fsquare_times _x88 88) _x88 in
let _x220 = S.fmul (SI.fsquare_times _x176 44) _x44 in
let _x223 = S.fmul (SI.fsquare_times _x220 3) _x3 in
feval h1 tmp == _x223 /\ feval h1 x88 == _x88 /\
inv_lazy_reduced2 h1 tmp /\ inv_lazy_reduced2 h1 x88))
let fexp_223 x3 x44 x88 tmp =
let h7 = ST.get () in
fsquare_times x88 x44 44ul;
fmul x88 x88 x44; // x88 = S.fmul (fsquare_times x44 44) x44
let h8 = ST.get () in
assert (feval h8 x88 == S.fmul (SI.fsquare_times (feval h7 x44) 44) (feval h7 x44));
fsquare_times tmp x88 88ul;
fmul tmp tmp x88; // tmp = x176 = S.fmul (fsquare_times x88 88) x88
let h9 = ST.get () in
assert (feval h9 tmp == S.fmul (SI.fsquare_times (feval h8 x88) 88) (feval h8 x88));
fsquare_times_in_place tmp 44ul;
fmul tmp tmp x44; // tmp = x220 = S.fmul (fsquare_times x176 44) x44
let h10 = ST.get () in
assert (feval h10 tmp == S.fmul (SI.fsquare_times (feval h9 tmp) 44) (feval h7 x44));
fsquare_times_in_place tmp 3ul;
fmul tmp tmp x3; // tmp = x223 = S.fmul (fsquare_times x220 3) x3
let h11 = ST.get () in
assert (feval h11 tmp == S.fmul (SI.fsquare_times (feval h10 tmp) 3) (feval h7 x3))
val fexp_223_23 (out x2 f:felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ live h x2 /\
disjoint out f /\ disjoint out x2 /\ disjoint f x2 /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc x2) h0 h1 /\
inv_lazy_reduced2 h1 out /\ inv_lazy_reduced2 h1 x2 /\
(feval h1 out, feval h1 x2) == SI.fexp_223_23 (feval h0 f))
[@CInline]
let fexp_223_23 out x2 f =
push_frame ();
let x3 = create_felem () in
let x22 = create_felem () in
let x44 = create_felem () in
let x88 = create_felem () in
let h0 = ST.get () in
fsquare_times x2 f 1ul;
fmul x2 x2 f; // x2 = S.fmul (fsquare_times f 1) f
let h1 = ST.get () in
assert (feval h1 x2 == S.fmul (SI.fsquare_times (feval h0 f) 1) (feval h0 f));
assert (modifies (loc x2) h0 h1);
fsquare_times x3 x2 1ul;
fmul x3 x3 f; // x3 = S.fmul (fsquare_times x2 1) f
let h2 = ST.get () in
assert (feval h2 x3 == S.fmul (SI.fsquare_times (feval h1 x2) 1) (feval h0 f));
assert (modifies (loc x3) h1 h2);
fexp_44 x2 x3 x22 x44 out;
fexp_223 x3 x44 x88 out;
let h3 = ST.get () in
assert (modifies (loc x22 |+| loc x44 |+| loc x88 |+| loc out) h2 h3);
fsquare_times_in_place out 23ul;
fmul out out x22; // out = r = S.fmul (fsquare_times x223 23) x22
let h4 = ST.get () in
assert (feval h4 out == S.fmul (SI.fsquare_times (feval h3 out) 23) (feval h3 x22));
pop_frame ()
val finv (out f: felem) : Stack unit
(requires fun h ->
live h out /\ live h f /\ disjoint out f /\
inv_lazy_reduced2 h f)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
feval h1 out == S.finv (feval h0 f) /\
inv_lazy_reduced2 h1 out) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Finv.fst.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.Exponentiation.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.Finv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Finv",
"short_module": "SI"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.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 | out: Hacl.K256.Field.felem -> f: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Prims._assert",
"Prims.l_and",
"Prims.eq2",
"Spec.K256.PointOps.felem",
"Hacl.K256.Field.feval",
"Spec.K256.PointOps.finv",
"Hacl.K256.Field.inv_lazy_reduced2",
"Spec.K256.PointOps.fmul",
"Hacl.Spec.K256.Finv.fsquare_times",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.Finv.fsquare_times_in_place",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.Finv.fexp_223_23",
"Hacl.K256.Field.create_felem",
"FStar.HyperStack.ST.push_frame",
"Hacl.Spec.K256.Finv.finv_is_finv_lemma"
] | [] | false | true | false | false | false | let finv out f =
| let h0 = ST.get () in
SI.finv_is_finv_lemma (feval h0 f);
push_frame ();
let x2 = create_felem () in
fexp_223_23 out x2 f;
let h1 = ST.get () in
fsquare_times_in_place out 5ul;
fmul out out f;
let h2 = ST.get () in
assert (feval h2 out == S.fmul (SI.fsquare_times (feval h1 out) 5) (feval h0 f));
fsquare_times_in_place out 3ul;
fmul out out x2;
let h3 = ST.get () in
assert (feval h3 out == S.fmul (SI.fsquare_times (feval h2 out) 3) (feval h1 x2));
fsquare_times_in_place out 2ul;
fmul out out f;
let h4 = ST.get () in
assert (feval h4 out == S.fmul (SI.fsquare_times (feval h3 out) 2) (feval h0 f));
assert (feval h4 out == S.finv (feval h0 f) /\ inv_lazy_reduced2 h4 out);
pop_frame () | false |
Hacl.Impl.K256.PointAdd.fst | Hacl.Impl.K256.PointAdd.point_add_xy_pairs | val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10)) | val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10)) | let point_add_xy_pairs x1 y1 x2 y2 xx yy tmp xy_pairs =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x1) (as_felem5 h0 y1);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x2) (as_felem5 h0 y2);
fadd xy_pairs x1 y1;
fadd tmp x2 y2;
let h1 = ST.get () in
assert (felem_fits5 (as_felem5 h1 xy_pairs) (2,2,2,2,4));
assert (felem_fits5 (as_felem5 h1 tmp) (2,2,2,2,4));
fmul xy_pairs xy_pairs tmp;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 xy_pairs) (1,1,1,1,2));
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h2 xx) (as_felem5 h2 yy);
fadd tmp xx yy;
let h3 = ST.get () in
assert (felem_fits5 (as_felem5 h3 tmp) (2,2,2,2,4));
fsub xy_pairs xy_pairs tmp (u64 4);
let h4 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (2,2,2,2,4) (as_felem5 h3 xy_pairs) (as_felem5 h3 tmp) (u64 4);
assert (felem_fits5 (as_felem5 h4 xy_pairs) (9,9,9,9,10)) | {
"file_name": "code/k256/Hacl.Impl.K256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 60,
"start_col": 0,
"start_line": 40
} | module Hacl.Impl.K256.PointAdd
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 BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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.PointAdd.fst"
} | [
{
"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": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x1: Hacl.K256.Field.felem ->
y1: Hacl.K256.Field.felem ->
x2: Hacl.K256.Field.felem ->
y2: Hacl.K256.Field.felem ->
xx: Hacl.K256.Field.felem ->
yy: Hacl.K256.Field.felem ->
tmp: Hacl.K256.Field.felem ->
xy_pairs: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Prims._assert",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"Hacl.K256.Field.as_felem5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.unit",
"Hacl.Spec.K256.Field52.Lemmas.fsub5_lemma",
"Lib.IntTypes.u64",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fsub",
"Hacl.K256.Field.fadd",
"Hacl.Spec.K256.Field52.Lemmas.fadd5_lemma",
"Hacl.K256.Field.fmul"
] | [] | false | true | false | false | false | let point_add_xy_pairs x1 y1 x2 y2 xx yy tmp xy_pairs =
| let h0 = ST.get () in
BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h0 x1) (as_felem5 h0 y1);
BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h0 x2) (as_felem5 h0 y2);
fadd xy_pairs x1 y1;
fadd tmp x2 y2;
let h1 = ST.get () in
assert (felem_fits5 (as_felem5 h1 xy_pairs) (2, 2, 2, 2, 4));
assert (felem_fits5 (as_felem5 h1 tmp) (2, 2, 2, 2, 4));
fmul xy_pairs xy_pairs tmp;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 xy_pairs) (1, 1, 1, 1, 2));
BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h2 xx) (as_felem5 h2 yy);
fadd tmp xx yy;
let h3 = ST.get () in
assert (felem_fits5 (as_felem5 h3 tmp) (2, 2, 2, 2, 4));
fsub xy_pairs xy_pairs tmp (u64 4);
let h4 = ST.get () in
BL.fsub5_lemma (1, 1, 1, 1, 2) (2, 2, 2, 2, 4) (as_felem5 h3 xy_pairs) (as_felem5 h3 tmp) (u64 4);
assert (felem_fits5 (as_felem5 h4 xy_pairs) (9, 9, 9, 9, 10)) | false |
LList.ST.fst | LList.ST.empty_pts_to | val empty_pts_to (#opened:_) (a:Type0)
: STGhostT unit opened
emp
(fun _ -> empty a `is_list` []) | val empty_pts_to (#opened:_) (a:Type0)
: STGhostT unit opened
emp
(fun _ -> empty a `is_list` []) | let empty_pts_to #_ a =
intro_pure (empty a == null);
rewrite (pure _)
(is_list (empty a) []) | {
"file_name": "share/steel/examples/steel/LList.ST.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 32,
"end_line": 109,
"start_col": 0,
"start_line": 106
} | (*
Copyright 2021 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.
Author: Aseem Rastogi
*)
module LList.ST
open Steel.Memory
open Steel.ST.Effect
open Steel.ST.Util
open Steel.ST.Reference
#set-options "--ide_id_info_off"
let rec is_list #a ll l : Tot vprop (decreases l) =
match l with
| [] -> pure (ll == null)
| hd::tl ->
exists_ (fun (node:llist_node a) ->
pts_to ll full_perm node
`star`
pure (node.data == hd)
`star`
is_list node.next tl)
let empty a = null
module T = FStar.Tactics
let intro #_ #_ l node ll _ =
intro_pure (node.data == Cons?.hd l);
intro_exists
node
(fun node -> pts_to ll full_perm node
`star`
pure (node.data == Cons?.hd l)
`star`
is_list node.next (Cons?.tl l));
assert (exists_ (fun node -> pts_to ll full_perm node
`star`
pure (node.data == Cons?.hd l)
`star`
is_list node.next (Cons?.tl l)) ==
is_list ll (Cons?.hd l::Cons?.tl l))
by (T.norm [delta_only [`%is_list]; zeta; iota]);
rewrite
(exists_ (fun node -> pts_to ll full_perm node
`star`
pure (node.data == Cons?.hd l)
`star`
is_list node.next (Cons?.tl l)))
(is_list ll l)
let elim_aux (#opened:_) (#a:Type0)
(hd:G.erased a)
(tl:G.erased (list a))
(ll:llist a)
: STGhost (G.erased (llist_node a)) opened
(is_list ll (G.reveal hd::tl))
(fun node ->
pts_to ll full_perm node
`star`
is_list node.next tl)
(requires True)
(ensures fun node -> eq2 #a node.data hd)
= assert (is_list ll (G.reveal hd::tl) ==
exists_ (fun node -> pts_to ll full_perm node
`star`
pure (eq2 #a node.data hd)
`star`
is_list node.next tl))
by (T.norm [delta_only [`%is_list]; zeta; iota]);
rewrite (is_list ll (G.reveal hd::tl))
(exists_ (fun node -> pts_to ll full_perm node
`star`
pure (eq2 #a node.data hd)
`star`
is_list node.next tl));
let node = elim_exists () in
elim_pure (eq2 _ _);
node
let elim #opened #a l ll p =
rewrite
(is_list ll l)
(is_list ll (Cons?.hd l::Cons?.tl l));
elim_aux (Cons?.hd l) (Cons?.tl l) ll | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "LList.ST.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"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": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "LList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LList",
"short_module": null
},
{
"abbrev": 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: Type0 -> Steel.ST.Effect.Ghost.STGhostT Prims.unit | Steel.ST.Effect.Ghost.STGhostT | [] | [] | [
"Steel.Memory.inames",
"Steel.ST.Util.rewrite",
"Steel.ST.Util.pure",
"Prims.eq2",
"Steel.ST.Reference.ref",
"LList.ST.llist_node",
"LList.ST.empty",
"Steel.ST.Reference.null",
"LList.ST.is_list",
"Prims.Nil",
"Prims.unit",
"Steel.ST.Util.intro_pure"
] | [] | false | true | false | false | false | let empty_pts_to #_ a =
| intro_pure (empty a == null);
rewrite (pure _) (is_list (empty a) []) | false |
Hacl.Impl.K256.PointAdd.fst | Hacl.Impl.K256.PointAdd.yy_mp_bzz3 | val yy_mp_bzz3 (zz yy tmp1 yy_m_bzz3 yy_p_bzz3:felem) : Stack unit
(requires fun h ->
live h zz /\ live h yy /\ live h tmp1 /\
live h yy_m_bzz3 /\ live h yy_p_bzz3 /\
disjoint zz yy /\ disjoint zz tmp1 /\ disjoint zz yy_m_bzz3 /\
disjoint zz yy_p_bzz3 /\ disjoint yy tmp1 /\ disjoint yy yy_m_bzz3 /\
disjoint yy yy_p_bzz3 /\ disjoint tmp1 yy_m_bzz3 /\
disjoint tmp1 yy_p_bzz3 /\ disjoint yy_m_bzz3 yy_p_bzz3 /\
inv_lazy_reduced2 h zz /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 ->
modifies (loc tmp1 |+| loc yy_m_bzz3 |+| loc yy_p_bzz3) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 yy_m_bzz3 = S.fsub (feval h0 yy) bzz3 /\
feval h1 yy_p_bzz3 = S.fadd (feval h0 yy) bzz3 /\
felem_fits5 (as_felem5 h1 yy_m_bzz3) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h1 yy_p_bzz3) (2,2,2,2,4))) | val yy_mp_bzz3 (zz yy tmp1 yy_m_bzz3 yy_p_bzz3:felem) : Stack unit
(requires fun h ->
live h zz /\ live h yy /\ live h tmp1 /\
live h yy_m_bzz3 /\ live h yy_p_bzz3 /\
disjoint zz yy /\ disjoint zz tmp1 /\ disjoint zz yy_m_bzz3 /\
disjoint zz yy_p_bzz3 /\ disjoint yy tmp1 /\ disjoint yy yy_m_bzz3 /\
disjoint yy yy_p_bzz3 /\ disjoint tmp1 yy_m_bzz3 /\
disjoint tmp1 yy_p_bzz3 /\ disjoint yy_m_bzz3 yy_p_bzz3 /\
inv_lazy_reduced2 h zz /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 ->
modifies (loc tmp1 |+| loc yy_m_bzz3 |+| loc yy_p_bzz3) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 yy_m_bzz3 = S.fsub (feval h0 yy) bzz3 /\
feval h1 yy_p_bzz3 = S.fadd (feval h0 yy) bzz3 /\
felem_fits5 (as_felem5 h1 yy_m_bzz3) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h1 yy_p_bzz3) (2,2,2,2,4))) | let yy_mp_bzz3 zz yy tmp1 yy_m_bzz3 yy_p_bzz3 =
fmul_3b_normalize_weak tmp1 zz; //tmp1 = bzz3 = (3*b)*zz
let h1 = ST.get () in
// assert (felem_fits5 (as_felem5 h1 tmp1) (1,1,1,1,2));
fsub yy_m_bzz3 yy tmp1 (u64 2); //yy_m_bzz3 = yy-bzz3
let h2 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 tmp1) (u64 2);
// assert (felem_fits5 (as_felem5 h5 yy_m_bzz3) (5,5,5,5,6));
fadd yy_p_bzz3 yy tmp1; //yy_p_bzz3 = yy+bzz3
let h3 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 tmp1) | {
"file_name": "code/k256/Hacl.Impl.K256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 158,
"start_col": 0,
"start_line": 146
} | module Hacl.Impl.K256.PointAdd
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 BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10))
let point_add_xy_pairs x1 y1 x2 y2 xx yy tmp xy_pairs =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x1) (as_felem5 h0 y1);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x2) (as_felem5 h0 y2);
fadd xy_pairs x1 y1;
fadd tmp x2 y2;
let h1 = ST.get () in
assert (felem_fits5 (as_felem5 h1 xy_pairs) (2,2,2,2,4));
assert (felem_fits5 (as_felem5 h1 tmp) (2,2,2,2,4));
fmul xy_pairs xy_pairs tmp;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 xy_pairs) (1,1,1,1,2));
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h2 xx) (as_felem5 h2 yy);
fadd tmp xx yy;
let h3 = ST.get () in
assert (felem_fits5 (as_felem5 h3 tmp) (2,2,2,2,4));
fsub xy_pairs xy_pairs tmp (u64 4);
let h4 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (2,2,2,2,4) (as_felem5 h3 xy_pairs) (as_felem5 h3 tmp) (u64 4);
assert (felem_fits5 (as_felem5 h4 xy_pairs) (9,9,9,9,10))
inline_for_extraction noextract
val ab_plus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (3,3,3,3,6) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fadd
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c)
let ab_plus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c);
fadd c tmp c;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (2,2,2,2,4));
fnormalize_weak c c;
BL.normalize_weak5_lemma (2,2,2,2,4) (as_felem5 h2 c)
inline_for_extraction noextract
val ab_minus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (1,1,1,1,2) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fsub
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c)
let ab_minus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c) (u64 2);
fsub c tmp c (u64 2);
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (5,5,5,5,6));
fnormalize_weak c c;
BL.normalize_weak5_lemma (5,5,5,5,6) (as_felem5 h2 c)
inline_for_extraction noextract
val yy_mp_bzz3 (zz yy tmp1 yy_m_bzz3 yy_p_bzz3:felem) : Stack unit
(requires fun h ->
live h zz /\ live h yy /\ live h tmp1 /\
live h yy_m_bzz3 /\ live h yy_p_bzz3 /\
disjoint zz yy /\ disjoint zz tmp1 /\ disjoint zz yy_m_bzz3 /\
disjoint zz yy_p_bzz3 /\ disjoint yy tmp1 /\ disjoint yy yy_m_bzz3 /\
disjoint yy yy_p_bzz3 /\ disjoint tmp1 yy_m_bzz3 /\
disjoint tmp1 yy_p_bzz3 /\ disjoint yy_m_bzz3 yy_p_bzz3 /\
inv_lazy_reduced2 h zz /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 ->
modifies (loc tmp1 |+| loc yy_m_bzz3 |+| loc yy_p_bzz3) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 yy_m_bzz3 = S.fsub (feval h0 yy) bzz3 /\
feval h1 yy_p_bzz3 = S.fadd (feval h0 yy) bzz3 /\
felem_fits5 (as_felem5 h1 yy_m_bzz3) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h1 yy_p_bzz3) (2,2,2,2,4))) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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.PointAdd.fst"
} | [
{
"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": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
zz: Hacl.K256.Field.felem ->
yy: Hacl.K256.Field.felem ->
tmp1: Hacl.K256.Field.felem ->
yy_m_bzz3: Hacl.K256.Field.felem ->
yy_p_bzz3: Hacl.K256.Field.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.K256.Field.felem",
"Hacl.Spec.K256.Field52.Lemmas.fadd5_lemma",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Hacl.K256.Field.as_felem5",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Field.fadd",
"Hacl.Spec.K256.Field52.Lemmas.fsub5_lemma",
"Lib.IntTypes.u64",
"Hacl.K256.Field.fsub",
"Hacl.K256.Field.fmul_3b_normalize_weak"
] | [] | false | true | false | false | false | let yy_mp_bzz3 zz yy tmp1 yy_m_bzz3 yy_p_bzz3 =
| fmul_3b_normalize_weak tmp1 zz;
let h1 = ST.get () in
fsub yy_m_bzz3 yy tmp1 (u64 2);
let h2 = ST.get () in
BL.fsub5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h1 yy) (as_felem5 h1 tmp1) (u64 2);
fadd yy_p_bzz3 yy tmp1;
let h3 = ST.get () in
BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (as_felem5 h1 yy) (as_felem5 h1 tmp1) | false |
Hacl.Impl.K256.PointAdd.fst | Hacl.Impl.K256.PointAdd.point_add | val point_add (out p q:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint out p /\ eq_or_disjoint out q /\ eq_or_disjoint p q /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_add (point_eval h0 p) (point_eval h0 q)) | val point_add (out p q:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint out p /\ eq_or_disjoint out q /\ eq_or_disjoint p q /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_add (point_eval h0 p) (point_eval h0 q)) | let point_add out p q =
push_frame ();
let tmp = create (9ul *! nlimb) (u64 0) in
point_add_no_alloc out p q tmp;
pop_frame () | {
"file_name": "code/k256/Hacl.Impl.K256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 241,
"start_col": 0,
"start_line": 237
} | module Hacl.Impl.K256.PointAdd
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 BL = Hacl.Spec.K256.Field52.Lemmas
open Hacl.K256.Field
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_xy_pairs (x1 y1 x2 y2 xx yy tmp xy_pairs:felem) : Stack unit
(requires fun h ->
live h x1 /\ live h y1 /\ live h x2 /\ live h y2 /\
live h xx /\ live h yy /\ live h tmp /\ live h xy_pairs /\
eq_or_disjoint x1 y1 /\ eq_or_disjoint x2 y2 /\ eq_or_disjoint xx yy /\
disjoint x1 xy_pairs /\ disjoint y1 xy_pairs /\ disjoint x2 xy_pairs /\ disjoint y2 xy_pairs /\
disjoint x1 tmp /\ disjoint y1 tmp /\ disjoint x2 tmp /\ disjoint y2 tmp /\
disjoint xx xy_pairs /\ disjoint yy xy_pairs /\ disjoint xx tmp /\ disjoint yy tmp /\
disjoint xy_pairs tmp /\
inv_lazy_reduced2 h x1 /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h x2 /\ inv_lazy_reduced2 h y2 /\
inv_lazy_reduced2 h xx /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 -> modifies (loc xy_pairs |+| loc tmp) h0 h1 /\
feval h1 xy_pairs =
S.fsub
(S.fmul (S.fadd (feval h0 x1) (feval h0 y1)) (S.fadd (feval h0 x2) (feval h0 y2)))
(S.fadd (feval h0 xx) (feval h0 yy)) /\
felem_fits5 (as_felem5 h1 xy_pairs) (9,9,9,9,10))
let point_add_xy_pairs x1 y1 x2 y2 xx yy tmp xy_pairs =
let h0 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x1) (as_felem5 h0 y1);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h0 x2) (as_felem5 h0 y2);
fadd xy_pairs x1 y1;
fadd tmp x2 y2;
let h1 = ST.get () in
assert (felem_fits5 (as_felem5 h1 xy_pairs) (2,2,2,2,4));
assert (felem_fits5 (as_felem5 h1 tmp) (2,2,2,2,4));
fmul xy_pairs xy_pairs tmp;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 xy_pairs) (1,1,1,1,2));
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h2 xx) (as_felem5 h2 yy);
fadd tmp xx yy;
let h3 = ST.get () in
assert (felem_fits5 (as_felem5 h3 tmp) (2,2,2,2,4));
fsub xy_pairs xy_pairs tmp (u64 4);
let h4 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (2,2,2,2,4) (as_felem5 h3 xy_pairs) (as_felem5 h3 tmp) (u64 4);
assert (felem_fits5 (as_felem5 h4 xy_pairs) (9,9,9,9,10))
inline_for_extraction noextract
val ab_plus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (3,3,3,3,6) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fadd
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c)
let ab_plus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c);
fadd c tmp c;
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (2,2,2,2,4));
fnormalize_weak c c;
BL.normalize_weak5_lemma (2,2,2,2,4) (as_felem5 h2 c)
inline_for_extraction noextract
val ab_minus_cd (a b c d tmp:felem) : Stack unit
(requires fun h ->
live h a /\ live h b /\ live h c /\ live h d /\ live h tmp /\
disjoint a b /\ disjoint c d /\ eq_or_disjoint a b /\ eq_or_disjoint a d /\
disjoint a tmp /\ disjoint b tmp /\ disjoint c tmp /\ disjoint d tmp /\
felem_fits5 (as_felem5 h a) (9,9,9,9,10) /\
felem_fits5 (as_felem5 h b) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h c) (1,1,1,1,2) /\
felem_fits5 (as_felem5 h d) (9,9,9,9,10))
(ensures fun h0 _ h1 -> modifies (loc c |+| loc tmp) h0 h1 /\
feval h1 c ==
S.fsub
(S.fmul (feval h0 a) (feval h0 b))
(S.fmul (feval h0 c) (feval h0 d)) /\
inv_lazy_reduced2 h1 c)
let ab_minus_cd a b c d tmp =
fmul tmp a b;
fmul c c d;
let h1 = ST.get () in
assert (inv_lazy_reduced2 h1 tmp);
assert (inv_lazy_reduced2 h1 c);
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 tmp) (as_felem5 h1 c) (u64 2);
fsub c tmp c (u64 2);
let h2 = ST.get () in
assert (felem_fits5 (as_felem5 h2 c) (5,5,5,5,6));
fnormalize_weak c c;
BL.normalize_weak5_lemma (5,5,5,5,6) (as_felem5 h2 c)
inline_for_extraction noextract
val yy_mp_bzz3 (zz yy tmp1 yy_m_bzz3 yy_p_bzz3:felem) : Stack unit
(requires fun h ->
live h zz /\ live h yy /\ live h tmp1 /\
live h yy_m_bzz3 /\ live h yy_p_bzz3 /\
disjoint zz yy /\ disjoint zz tmp1 /\ disjoint zz yy_m_bzz3 /\
disjoint zz yy_p_bzz3 /\ disjoint yy tmp1 /\ disjoint yy yy_m_bzz3 /\
disjoint yy yy_p_bzz3 /\ disjoint tmp1 yy_m_bzz3 /\
disjoint tmp1 yy_p_bzz3 /\ disjoint yy_m_bzz3 yy_p_bzz3 /\
inv_lazy_reduced2 h zz /\ inv_lazy_reduced2 h yy)
(ensures fun h0 _ h1 ->
modifies (loc tmp1 |+| loc yy_m_bzz3 |+| loc yy_p_bzz3) h0 h1 /\
(let bzz3 = S.fmul (S.fmul 3 S.b) (feval h0 zz) in
feval h1 yy_m_bzz3 = S.fsub (feval h0 yy) bzz3 /\
feval h1 yy_p_bzz3 = S.fadd (feval h0 yy) bzz3 /\
felem_fits5 (as_felem5 h1 yy_m_bzz3) (5,5,5,5,6) /\
felem_fits5 (as_felem5 h1 yy_p_bzz3) (2,2,2,2,4)))
let yy_mp_bzz3 zz yy tmp1 yy_m_bzz3 yy_p_bzz3 =
fmul_3b_normalize_weak tmp1 zz; //tmp1 = bzz3 = (3*b)*zz
let h1 = ST.get () in
// assert (felem_fits5 (as_felem5 h1 tmp1) (1,1,1,1,2));
fsub yy_m_bzz3 yy tmp1 (u64 2); //yy_m_bzz3 = yy-bzz3
let h2 = ST.get () in
BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 tmp1) (u64 2);
// assert (felem_fits5 (as_felem5 h5 yy_m_bzz3) (5,5,5,5,6));
fadd yy_p_bzz3 yy tmp1; //yy_p_bzz3 = yy+bzz3
let h3 = ST.get () in
BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (as_felem5 h1 yy) (as_felem5 h1 tmp1)
// assert (felem_fits5 (as_felem5 h6 yy_p_bzz3) (2,2,2,2,4));
#set-options "--z3rlimit 300"
inline_for_extraction noextract
val point_add_no_alloc (out p q:point) (tmp:lbuffer uint64 (9ul *! nlimb)) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\ live h tmp /\
eq_or_disjoint out p /\ eq_or_disjoint out q /\ eq_or_disjoint p q /\
disjoint p tmp /\ disjoint q tmp /\ disjoint out tmp /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_add (point_eval h0 p) (point_eval h0 q))
let point_add_no_alloc out p q tmp =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
let x3, y3, z3 = getx out, gety out, getz out in
let xx = sub tmp 0ul nlimb in
let yy = sub tmp nlimb nlimb in
let zz = sub tmp (2ul *! nlimb) nlimb in
let xy_pairs = sub tmp (3ul *! nlimb) nlimb in
let yz_pairs = sub tmp (4ul *! nlimb) nlimb in
let xz_pairs = sub tmp (5ul *! nlimb) nlimb in
let yy_m_bzz3 = sub tmp (6ul *! nlimb) nlimb in
let yy_p_bzz3 = sub tmp (7ul *! nlimb) nlimb in
let tmp1 = sub tmp (8ul *! nlimb) nlimb in
let h0 = ST.get () in
fmul xx x1 x2; //xx = x1*x2
fmul yy y1 y2; //yy = y1*y2
fmul zz z1 z2; //zz = z1*z2
let h1 = ST.get () in
// assert (inv_lazy_reduced2 h1 xx);
// assert (inv_lazy_reduced2 h1 yy);
// assert (inv_lazy_reduced2 h1 zz);
point_add_xy_pairs x1 y1 x2 y2 xx yy tmp1 xy_pairs; //xy_pairs = (x1+y1)*(x2+y2)-(xx+yy)
point_add_xy_pairs y1 z1 y2 z2 yy zz tmp1 yz_pairs; //yz_pairs = (y1+z1)*(y2+z2)-(yy+zz)
point_add_xy_pairs x1 z1 x2 z2 xx zz tmp1 xz_pairs; //xz_pairs = (x1+z1)*(x2+z2)-(xx+zz)
let h2 = ST.get () in
// assert (felem_fits5 (as_felem5 h2 xy_pairs) (9,9,9,9,10));
// assert (felem_fits5 (as_felem5 h2 yz_pairs) (9,9,9,9,10));
// assert (felem_fits5 (as_felem5 h2 xz_pairs) (9,9,9,9,10));
yy_mp_bzz3 zz yy tmp1 yy_m_bzz3 yy_p_bzz3;
fmul_3b_normalize_weak x3 yz_pairs; //x3 = byz3 = (3*b)*yz_pairs
let h7 = ST.get () in
// assert (felem_fits5 (as_felem5 h7 x3) (1,1,1,1,2));
fmul_small_num z3 xx (u64 3); //z3 = xx3 = 3*xx
let h8 = ST.get () in
BL.fmul15_lemma (1,1,1,1,2) 3 (as_felem5 h7 xx) (u64 3);
// assert (felem_fits5 (as_felem5 h8 z3) (3,3,3,3,6));
fmul_3b_normalize_weak y3 z3; //y3 = bxx9 = (3*b)*xx3
let h9 = ST.get () in
// assert (felem_fits5 (as_felem5 h9 y3) (1,1,1,1,2));
ab_minus_cd xy_pairs yy_m_bzz3 x3 xz_pairs tmp1; //x3 = (xy_pairs*yy_m_bzz3-byz3*xz_pairs)
ab_plus_cd yy_p_bzz3 yy_m_bzz3 y3 xz_pairs tmp1; //y3 = (yy_p_bzz3*yy_m_bzz3+bxx9*xz_pairs)
ab_plus_cd yz_pairs yy_p_bzz3 z3 xy_pairs tmp1 //z3 = (yz_pairs*yy_p_bzz3+xx3*xy_pairs)
val point_add (out p q:point) : Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint out p /\ eq_or_disjoint out q /\ eq_or_disjoint p q /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\
point_eval h1 out == S.point_add (point_eval h0 p) (point_eval h0 q)) | {
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Lemmas.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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.PointAdd.fst"
} | [
{
"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": "Hacl.Spec.K256.Field52.Lemmas",
"short_module": "BL"
},
{
"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": 300,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | out: Hacl.Impl.K256.Point.point -> p: Hacl.Impl.K256.Point.point -> q: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.K256.Point.point",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.K256.PointAdd.point_add_no_alloc",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Hacl.K256.Field.nlimb",
"Lib.Buffer.create",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let point_add out p q =
| push_frame ();
let tmp = create (9ul *! nlimb) (u64 0) in
point_add_no_alloc out p q tmp;
pop_frame () | false |
Tests.fst | Tests.test1 | val test1: Prims.unit -> Lemma (True) | val test1: Prims.unit -> Lemma (True) | let test1 () : Lemma (True) =
assert (length (empty #int) == 0);
assert (forall (s: seq bool). length s == 0 ==> s == empty);
assert (forall (v: list int). length (singleton v) == 1);
assert (forall (s: seq int) (v: int). length (build s v) == 1 + length s);
assert (forall (v: nat). index (singleton v) 0 == v);
assert (~(contains empty 42));
assert (forall (s: seq int). take s 0 == empty);
assert (forall (s: seq int). drop s 0 == s);
() | {
"file_name": "examples/sequence/Tests.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 51,
"start_col": 8,
"start_line": 42
} | (*
Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan
Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module includes tests of sequence properties.
@summary Tests sequence properties
*)
module Tests
open FStar.Sequence
open FStar.Sequence.Util | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Util.fst.checked",
"FStar.Sequence.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Tests.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.l_True) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"FStar.Sequence.Base.seq",
"Prims.int",
"Prims.eq2",
"FStar.Sequence.Base.drop",
"FStar.Sequence.Base.take",
"FStar.Sequence.Base.empty",
"Prims.l_not",
"FStar.Sequence.Base.contains",
"Prims.nat",
"FStar.Sequence.Base.index",
"FStar.Sequence.Base.singleton",
"FStar.Sequence.Base.length",
"FStar.Sequence.Base.build",
"Prims.op_Addition",
"Prims.list",
"Prims.bool",
"Prims.l_imp",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let test1 () : Lemma (True) =
| assert (length (empty #int) == 0);
assert (forall (s: seq bool). length s == 0 ==> s == empty);
assert (forall (v: list int). length (singleton v) == 1);
assert (forall (s: seq int) (v: int). length (build s v) == 1 + length s);
assert (forall (v: nat). index (singleton v) 0 == v);
assert (~(contains empty 42));
assert (forall (s: seq int). take s 0 == empty);
assert (forall (s: seq int). drop s 0 == s);
() | false |
BinaryTreesEnumeration.fst | BinaryTreesEnumeration.pws_complete | val pws_complete (m n: nat) :
Lemma (List.memP (m, n) (pairs_with_sum (m + n))) | val pws_complete (m n: nat) :
Lemma (List.memP (m, n) (pairs_with_sum (m + n))) | let pws_complete (m n: nat) :
Lemma (List.memP (m, n) (pairs_with_sum (m + n))) =
assert (pairs_with_sum (m + n) == pairs_with_sum' (m + n) 0);
pws'_complete m n 0 | {
"file_name": "examples/data_structures/BinaryTreesEnumeration.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 40,
"start_col": 0,
"start_line": 37
} | (*
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 BinaryTreesEnumeration
open FStar.List
let rec pairs_with_sum' m n =
(m, n) ::
(if m = 0
then []
else pairs_with_sum' (m - 1) (n + 1))
let rec pws'_complete (m d n: nat) :
Lemma (List.memP (m, n + d) (pairs_with_sum' (m + d) n)) =
if d = 0 then ()
else begin
assert (m + d <> 0);
pws'_complete m (d - 1) (n + 1);
assert (List.memP (m, (n + 1) + (d - 1)) (pairs_with_sum' (m + (d - 1)) (n + 1)));
assert (List.memP (m, n + d) (pairs_with_sum' (m + d) n))
end | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": true,
"source_file": "BinaryTreesEnumeration.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": 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 | m: Prims.nat -> n: Prims.nat
-> FStar.Pervasives.Lemma
(ensures FStar.List.Tot.Base.memP (m, n) (BinaryTreesEnumeration.pairs_with_sum (m + n))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"BinaryTreesEnumeration.pws'_complete",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.list",
"BinaryTreesEnumeration.prod_with_sum",
"Prims.op_Addition",
"BinaryTreesEnumeration.pairs_with_sum",
"BinaryTreesEnumeration.pairs_with_sum'",
"Prims.l_True",
"Prims.squash",
"FStar.List.Tot.Base.memP",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let pws_complete (m n: nat) : Lemma (List.memP (m, n) (pairs_with_sum (m + n))) =
| assert (pairs_with_sum (m + n) == pairs_with_sum' (m + n) 0);
pws'_complete m n 0 | false |
BinaryTreesEnumeration.fst | BinaryTreesEnumeration.pairs_with_sum' | val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) | val pairs_with_sum' : m:nat -> n:nat -> list (prod_with_sum (m + n)) | let rec pairs_with_sum' m n =
(m, n) ::
(if m = 0
then []
else pairs_with_sum' (m - 1) (n + 1)) | {
"file_name": "examples/data_structures/BinaryTreesEnumeration.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 24,
"start_col": 0,
"start_line": 20
} | (*
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 BinaryTreesEnumeration
open FStar.List | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": true,
"source_file": "BinaryTreesEnumeration.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": 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 | m: Prims.nat -> n: Prims.nat -> Prims.list (BinaryTreesEnumeration.prod_with_sum (m + n)) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.Cons",
"BinaryTreesEnumeration.prod_with_sum",
"Prims.op_Addition",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Equality",
"Prims.int",
"Prims.Nil",
"Prims.bool",
"BinaryTreesEnumeration.pairs_with_sum'",
"Prims.list"
] | [
"recursion"
] | false | false | false | false | false | let rec pairs_with_sum' m n =
| (m, n) :: (if m = 0 then [] else pairs_with_sum' (m - 1) (n + 1)) | false |
Tests.fst | Tests.test5 | val test5 (s: seq int) : Tot int (decreases length s) | val test5 (s: seq int) : Tot int (decreases length s) | let rec test5 (s: seq int) : Tot int (decreases length s) =
if length s = 0 then
0
else
1 + test5 (take s (length s - 1)) | {
"file_name": "examples/sequence/Tests.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 90,
"start_col": 8,
"start_line": 86
} | (*
Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan
Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module includes tests of sequence properties.
@summary Tests sequence properties
*)
module Tests
open FStar.Sequence
open FStar.Sequence.Util
(** test1 asserts various statements that trivially follow from the ambient sequence facts **)
private let test1 () : Lemma (True) =
assert (length (empty #int) == 0);
assert (forall (s: seq bool). length s == 0 ==> s == empty);
assert (forall (v: list int). length (singleton v) == 1);
assert (forall (s: seq int) (v: int). length (build s v) == 1 + length s);
assert (forall (v: nat). index (singleton v) 0 == v);
assert (~(contains empty 42));
assert (forall (s: seq int). take s 0 == empty);
assert (forall (s: seq int). drop s 0 == s);
()
(** test2 builds a sequence [1; 2; 3; 4; 5] and asserts various properties about it **)
private let test2 () : Lemma (True) =
let s1 = empty $:: 1 in
let s2 = s1 $:: 2 in
let s3 = s2 $:: 3 in
let s4 = s3 $:: 4 in
let s5 = s4 $:: 5 in
assert (length s2 = 1 + length s1);
assert (length s2 = 2);
assert (length s5 = 5);
assert (s5 $@ 1 == 2);
assert (forall (s: seq int) (n: nat). n < 2 ==> (s2 $+ s) $@ n = s2 $@ n);
assert (drop (drop s5 1) 2 == drop s5 3);
assert (forall (v: int). length (s5 $:: v) = 6);
assert (s3 $<= s5);
assert (length (update s5 3 7) == 5);
assert ((update s5 3 7) $@ 2 == 3);
assert ((update s5 3 7) $@ 3 == 7);
assert (length (slice s5 1 3) == 2)
(** test3 establishes that appending a take and a drop with the same index produces the same sequence **)
private let test3 (s: seq int) (n: nat{n <= length s})
: Lemma (s $== ((take s n) $+ (drop s n))) =
()
(** test4 tests the use of rank to establish a decreases clause **)
private let rec test4 (s: seq int) : Tot int (decreases rank s) =
if length s = 0 then
0
else
1 + test4 (drop s 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Util.fst.checked",
"FStar.Sequence.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Tests.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Sequence.Base.seq Prims.int -> Prims.Tot Prims.int | Prims.Tot | [
"total",
""
] | [] | [
"FStar.Sequence.Base.seq",
"Prims.int",
"Prims.op_Equality",
"FStar.Sequence.Base.length",
"Prims.bool",
"Prims.op_Addition",
"Tests.test5",
"FStar.Sequence.Base.take",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | true | false | let rec test5 (s: seq int) : Tot int (decreases length s) =
| if length s = 0 then 0 else 1 + test5 (take s (length s - 1)) | false |
BinaryTreesEnumeration.fst | BinaryTreesEnumeration.pws'_complete | val pws'_complete (m d n: nat) : Lemma (List.memP (m, n + d) (pairs_with_sum' (m + d) n)) | val pws'_complete (m d n: nat) : Lemma (List.memP (m, n + d) (pairs_with_sum' (m + d) n)) | let rec pws'_complete (m d n: nat) :
Lemma (List.memP (m, n + d) (pairs_with_sum' (m + d) n)) =
if d = 0 then ()
else begin
assert (m + d <> 0);
pws'_complete m (d - 1) (n + 1);
assert (List.memP (m, (n + 1) + (d - 1)) (pairs_with_sum' (m + (d - 1)) (n + 1)));
assert (List.memP (m, n + d) (pairs_with_sum' (m + d) n))
end | {
"file_name": "examples/data_structures/BinaryTreesEnumeration.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 34,
"start_col": 0,
"start_line": 26
} | (*
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 BinaryTreesEnumeration
open FStar.List
let rec pairs_with_sum' m n =
(m, n) ::
(if m = 0
then []
else pairs_with_sum' (m - 1) (n + 1)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked"
],
"interface_file": true,
"source_file": "BinaryTreesEnumeration.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": 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 | m: Prims.nat -> d: Prims.nat -> n: Prims.nat
-> FStar.Pervasives.Lemma
(ensures FStar.List.Tot.Base.memP (m, n + d) (BinaryTreesEnumeration.pairs_with_sum' (m + d) n)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims._assert",
"FStar.List.Tot.Base.memP",
"BinaryTreesEnumeration.prod_with_sum",
"Prims.op_Addition",
"FStar.Pervasives.Native.Mktuple2",
"BinaryTreesEnumeration.pairs_with_sum'",
"Prims.unit",
"Prims.op_Subtraction",
"BinaryTreesEnumeration.pws'_complete",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec pws'_complete (m d n: nat) : Lemma (List.memP (m, n + d) (pairs_with_sum' (m + d) n)) =
| if d = 0
then ()
else
(assert (m + d <> 0);
pws'_complete m (d - 1) (n + 1);
assert (List.memP (m, (n + 1) + (d - 1)) (pairs_with_sum' (m + (d - 1)) (n + 1)));
assert (List.memP (m, n + d) (pairs_with_sum' (m + d) n))) | false |
Tests.fst | Tests.test4 | val test4 (s: seq int) : Tot int (decreases rank s) | val test4 (s: seq int) : Tot int (decreases rank s) | let rec test4 (s: seq int) : Tot int (decreases rank s) =
if length s = 0 then
0
else
1 + test4 (drop s 1) | {
"file_name": "examples/sequence/Tests.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 83,
"start_col": 8,
"start_line": 79
} | (*
Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan
Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module includes tests of sequence properties.
@summary Tests sequence properties
*)
module Tests
open FStar.Sequence
open FStar.Sequence.Util
(** test1 asserts various statements that trivially follow from the ambient sequence facts **)
private let test1 () : Lemma (True) =
assert (length (empty #int) == 0);
assert (forall (s: seq bool). length s == 0 ==> s == empty);
assert (forall (v: list int). length (singleton v) == 1);
assert (forall (s: seq int) (v: int). length (build s v) == 1 + length s);
assert (forall (v: nat). index (singleton v) 0 == v);
assert (~(contains empty 42));
assert (forall (s: seq int). take s 0 == empty);
assert (forall (s: seq int). drop s 0 == s);
()
(** test2 builds a sequence [1; 2; 3; 4; 5] and asserts various properties about it **)
private let test2 () : Lemma (True) =
let s1 = empty $:: 1 in
let s2 = s1 $:: 2 in
let s3 = s2 $:: 3 in
let s4 = s3 $:: 4 in
let s5 = s4 $:: 5 in
assert (length s2 = 1 + length s1);
assert (length s2 = 2);
assert (length s5 = 5);
assert (s5 $@ 1 == 2);
assert (forall (s: seq int) (n: nat). n < 2 ==> (s2 $+ s) $@ n = s2 $@ n);
assert (drop (drop s5 1) 2 == drop s5 3);
assert (forall (v: int). length (s5 $:: v) = 6);
assert (s3 $<= s5);
assert (length (update s5 3 7) == 5);
assert ((update s5 3 7) $@ 2 == 3);
assert ((update s5 3 7) $@ 3 == 7);
assert (length (slice s5 1 3) == 2)
(** test3 establishes that appending a take and a drop with the same index produces the same sequence **)
private let test3 (s: seq int) (n: nat{n <= length s})
: Lemma (s $== ((take s n) $+ (drop s n))) =
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Util.fst.checked",
"FStar.Sequence.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Tests.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Sequence.Base.seq Prims.int -> Prims.Tot Prims.int | Prims.Tot | [
"total",
""
] | [] | [
"FStar.Sequence.Base.seq",
"Prims.int",
"Prims.op_Equality",
"FStar.Sequence.Base.length",
"Prims.bool",
"Prims.op_Addition",
"Tests.test4",
"FStar.Sequence.Base.drop"
] | [
"recursion"
] | false | false | false | true | false | let rec test4 (s: seq int) : Tot int (decreases rank s) =
| if length s = 0 then 0 else 1 + test4 (drop s 1) | false |
Tests.fst | Tests.test2 | val test2: Prims.unit -> Lemma (True) | val test2: Prims.unit -> Lemma (True) | let test2 () : Lemma (True) =
let s1 = empty $:: 1 in
let s2 = s1 $:: 2 in
let s3 = s2 $:: 3 in
let s4 = s3 $:: 4 in
let s5 = s4 $:: 5 in
assert (length s2 = 1 + length s1);
assert (length s2 = 2);
assert (length s5 = 5);
assert (s5 $@ 1 == 2);
assert (forall (s: seq int) (n: nat). n < 2 ==> (s2 $+ s) $@ n = s2 $@ n);
assert (drop (drop s5 1) 2 == drop s5 3);
assert (forall (v: int). length (s5 $:: v) = 6);
assert (s3 $<= s5);
assert (length (update s5 3 7) == 5);
assert ((update s5 3 7) $@ 2 == 3);
assert ((update s5 3 7) $@ 3 == 7);
assert (length (slice s5 1 3) == 2) | {
"file_name": "examples/sequence/Tests.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 71,
"start_col": 8,
"start_line": 54
} | (*
Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan
Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module includes tests of sequence properties.
@summary Tests sequence properties
*)
module Tests
open FStar.Sequence
open FStar.Sequence.Util
(** test1 asserts various statements that trivially follow from the ambient sequence facts **)
private let test1 () : Lemma (True) =
assert (length (empty #int) == 0);
assert (forall (s: seq bool). length s == 0 ==> s == empty);
assert (forall (v: list int). length (singleton v) == 1);
assert (forall (s: seq int) (v: int). length (build s v) == 1 + length s);
assert (forall (v: nat). index (singleton v) 0 == v);
assert (~(contains empty 42));
assert (forall (s: seq int). take s 0 == empty);
assert (forall (s: seq int). drop s 0 == s);
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Util.fst.checked",
"FStar.Sequence.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Tests.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.l_True) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"FStar.Sequence.Base.length",
"FStar.Sequence.Util.slice",
"FStar.Sequence.Base.op_Dollar_At",
"FStar.Sequence.Base.update",
"FStar.Sequence.Base.op_Dollar_Less_Equals",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Sequence.Base.op_Dollar_Colon_Colon",
"FStar.Sequence.Base.seq",
"FStar.Sequence.Base.drop",
"Prims.nat",
"Prims.l_imp",
"Prims.op_LessThan",
"FStar.Sequence.Base.op_Dollar_Plus",
"Prims.op_Addition",
"FStar.Sequence.Base.empty",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let test2 () : Lemma (True) =
| let s1 = empty $:: 1 in
let s2 = s1 $:: 2 in
let s3 = s2 $:: 3 in
let s4 = s3 $:: 4 in
let s5 = s4 $:: 5 in
assert (length s2 = 1 + length s1);
assert (length s2 = 2);
assert (length s5 = 5);
assert (s5 $@ 1 == 2);
assert (forall (s: seq int) (n: nat). n < 2 ==> (s2 $+ s) $@ n = s2 $@ n);
assert (drop (drop s5 1) 2 == drop s5 3);
assert (forall (v: int). length (s5 $:: v) = 6);
assert (s3 $<= s5);
assert (length (update s5 3 7) == 5);
assert ((update s5 3 7) $@ 2 == 3);
assert ((update s5 3 7) $@ 3 == 7);
assert (length (slice s5 1 3) == 2) | false |
Vale.PPC64LE.InsBasic.fsti | Vale.PPC64LE.InsBasic.vale_heap | val vale_heap : Type | let vale_heap = Vale.PPC64LE.Memory.vale_heap | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 8,
"start_col": 7,
"start_line": 8
} | module Vale.PPC64LE.InsBasic
open FStar.Mul
open Vale.Arch.Types
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.InsBasic.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": 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": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Memory.vale_heap"
] | [] | false | false | false | true | true | let vale_heap =
| Vale.PPC64LE.Memory.vale_heap | false |
|
Vale.PPC64LE.InsBasic.fsti | Vale.PPC64LE.InsBasic.va_wp_Move | val va_wp_Move (dst src: va_operand_reg_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_Move (dst src: va_operand_reg_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_Move (dst:va_operand_reg_opr) (src:va_operand_reg_opr) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_reg_opr dst va_s0 /\ va_is_src_reg_opr src va_s0 /\ va_get_ok va_s0 /\ (forall
(va_x_dst:va_value_reg_opr) . let va_sM = va_upd_operand_reg_opr dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_reg_opr va_sM dst == va_eval_reg_opr va_s0 src ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 99,
"end_line": 29,
"start_col": 0,
"start_line": 25
} | module Vale.PPC64LE.InsBasic
open FStar.Mul
open Vale.Arch.Types
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let vale_heap = Vale.PPC64LE.Memory.vale_heap
unfold let vale_stack = Vale.PPC64LE.Stack_i.vale_stack
//-- Move
val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code
val va_codegen_success_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_pbool
val va_lemma_Move : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr ->
src:va_operand_reg_opr
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Move dst src) va_s0 /\ va_is_dst_reg_opr dst va_s0 /\
va_is_src_reg_opr src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_reg_opr va_sM dst == va_eval_reg_opr va_s0 src /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_reg_opr dst va_sM va_s0)))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.InsBasic.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": 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": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_reg_opr ->
src: Vale.PPC64LE.Decls.va_operand_reg_opr ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.PPC64LE.Decls.va_is_dst_reg_opr",
"Vale.PPC64LE.Decls.va_is_src_reg_opr",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.l_Forall",
"Vale.PPC64LE.Decls.va_value_reg_opr",
"Prims.l_imp",
"Prims.eq2",
"Vale.PPC64LE.Machine_s.nat64",
"Vale.PPC64LE.Decls.va_eval_reg_opr",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_operand_reg_opr"
] | [] | false | false | false | true | true | let va_wp_Move (dst src: va_operand_reg_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_is_dst_reg_opr dst va_s0 /\ va_is_src_reg_opr src va_s0 /\ va_get_ok va_s0 /\
(forall (va_x_dst: va_value_reg_opr).
let va_sM = va_upd_operand_reg_opr dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_reg_opr va_sM dst == va_eval_reg_opr va_s0 src ==> va_k va_sM (()))
) | false |
Tests.fst | Tests.test6 | val test6: Prims.unit -> Lemma (True) | val test6: Prims.unit -> Lemma (True) | let test6 () : Lemma (True) =
assert (forall (ty: Type).{:pattern empty #ty} length (empty #ty) = 0);
assert (forall (ty: Type) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty);
assert (forall (ty: Type) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1);
assert (forall (ty: Type) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s);
assert (forall (ty: Type) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)}
length (append s0 s1) = length s0 + length s1);
assert (forall (ty: Type) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)}
length (update s i v) = length s);
assert (forall (ty: Type) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)})
.{:pattern index (update s i v) n}
n < length s ==>
(i = n ==> index (update s i v) n == v)
/\ (i <> n ==> index (update s i v) n == index s n));
assert (forall (ty: Type) (s: seq ty) (x: ty).{:pattern contains s x}
contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x));
assert (forall (ty: Type) (x: ty).{:pattern contains empty x} ~(contains empty x));
assert (forall (ty: Type) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x}
contains (build s v) x <==> (v == x \/ contains s x));
assert (forall (ty: Type) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (take s n) x}
contains (take s n) x <==>
(exists (i: nat).{:pattern index s i} i < n /\ i < length s /\ index s i == x));
assert (forall (ty: Type) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (drop s n) x}
contains (drop s n) x <==>
(exists (i: nat).{:pattern index s i} n <= i && i < length s /\ index s i == x));
assert (forall (ty: Type) (s0: seq ty) (s1: seq ty).{:pattern equal s0 s1}
equal s0 s1 <==>
length s0 == length s1 /\
(forall j.{:pattern index s0 j \/ index s1 j}
0 <= j && j < length s0 ==> index s0 j == index s1 j));
assert (forall (ty: Type) (a: seq ty) (b: seq ty).{:pattern equal a b} equal a b ==> a == b);
assert (forall (ty: Type) (s0: seq ty) (s1: seq ty).{:pattern is_prefix s0 s1}
is_prefix s0 s1 <==>
length s0 <= length s1
/\ (forall (j: nat).{:pattern index s0 j \/ index s1 j}
j < length s0 ==> index s0 j == index s1 j));
assert (forall (ty: Type) (s: seq ty) (n: nat).{:pattern length (take s n)}
n <= length s ==> length (take s n) = n);
assert (forall (ty: Type) (s: seq ty) (n: nat). {:pattern length (drop s n)}
n <= length s ==> length (drop s n) = length s - n);
assert (forall (ty: Type) (v: ty).{:pattern rank v} rank v == v);
assert (forall (ty: Type) (s: seq ty) (i: nat).{:pattern rank (index s i)}
i < length s ==> rank (index s i) << rank s);
assert (forall (ty: Type) (s: seq ty) (i: nat).{:pattern rank (drop s i)}
0 < i && i <= length s ==> rank (drop s i) << rank s);
assert (forall (ty: Type) (s: seq ty) (i: nat).{:pattern length (take s i)}
i < length s ==> length (take s i) << length s);
assert (forall (ty: Type) (s: seq ty) (i: nat) (j: nat).{:pattern length (append (take s i) (drop s j))}
i < j && j <= length s ==> length (append (take s i) (drop s j)) << length s);
assert (forall (ty: Type) (s: seq ty) (n: nat).{:pattern drop s n} n = 0 ==> drop s n == s);
assert (forall (ty: Type) (s: seq ty) (n: nat).{:pattern take s n} n = 0 ==> take s n == empty);
assert (forall (ty: Type) (s: seq ty) (m: nat) (n: nat).{:pattern drop (drop s m) n}
m + n <= length s ==> drop (drop s m) n == drop s (m + n)) | {
"file_name": "examples/sequence/Tests.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 70,
"end_line": 145,
"start_col": 8,
"start_line": 93
} | (*
Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan
Rosen, Nikhil Swamy, Microsoft Research, and contributors to
the Dafny Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Includes material from the Dafny project
(https://github.com/dafny-lang/dafny) which carries this license
information:
Created 9 February 2008 by Rustan Leino.
Converted to Boogie 2 on 28 June 2008.
Edited sequence axioms 20 October 2009 by Alex Summers.
Modified 2014 by Dan Rosen.
Copyright (c) 2008-2014, Microsoft.
Copyright by the contributors to the Dafny Project
SPDX-License-Identifier: MIT
*)
(**
This module includes tests of sequence properties.
@summary Tests sequence properties
*)
module Tests
open FStar.Sequence
open FStar.Sequence.Util
(** test1 asserts various statements that trivially follow from the ambient sequence facts **)
private let test1 () : Lemma (True) =
assert (length (empty #int) == 0);
assert (forall (s: seq bool). length s == 0 ==> s == empty);
assert (forall (v: list int). length (singleton v) == 1);
assert (forall (s: seq int) (v: int). length (build s v) == 1 + length s);
assert (forall (v: nat). index (singleton v) 0 == v);
assert (~(contains empty 42));
assert (forall (s: seq int). take s 0 == empty);
assert (forall (s: seq int). drop s 0 == s);
()
(** test2 builds a sequence [1; 2; 3; 4; 5] and asserts various properties about it **)
private let test2 () : Lemma (True) =
let s1 = empty $:: 1 in
let s2 = s1 $:: 2 in
let s3 = s2 $:: 3 in
let s4 = s3 $:: 4 in
let s5 = s4 $:: 5 in
assert (length s2 = 1 + length s1);
assert (length s2 = 2);
assert (length s5 = 5);
assert (s5 $@ 1 == 2);
assert (forall (s: seq int) (n: nat). n < 2 ==> (s2 $+ s) $@ n = s2 $@ n);
assert (drop (drop s5 1) 2 == drop s5 3);
assert (forall (v: int). length (s5 $:: v) = 6);
assert (s3 $<= s5);
assert (length (update s5 3 7) == 5);
assert ((update s5 3 7) $@ 2 == 3);
assert ((update s5 3 7) $@ 3 == 7);
assert (length (slice s5 1 3) == 2)
(** test3 establishes that appending a take and a drop with the same index produces the same sequence **)
private let test3 (s: seq int) (n: nat{n <= length s})
: Lemma (s $== ((take s n) $+ (drop s n))) =
()
(** test4 tests the use of rank to establish a decreases clause **)
private let rec test4 (s: seq int) : Tot int (decreases rank s) =
if length s = 0 then
0
else
1 + test4 (drop s 1)
(** test5 tests the use of length to establish a decreases clause in a case where rank won't work **)
private let rec test5 (s: seq int) : Tot int (decreases length s) =
if length s = 0 then
0
else
1 + test5 (take s (length s - 1)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Util.fst.checked",
"FStar.Sequence.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Tests.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.l_True) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"FStar.Sequence.Base.seq",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Sequence.Base.length",
"Prims.eq2",
"FStar.Sequence.Base.drop",
"Prims.op_Equality",
"Prims.int",
"FStar.Sequence.Base.take",
"FStar.Sequence.Base.empty",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"Prims.precedes",
"FStar.Sequence.Base.append",
"FStar.Sequence.Base.rank",
"FStar.Sequence.Base.index",
"Prims.op_Subtraction",
"Prims.l_iff",
"FStar.Sequence.Base.is_prefix",
"Prims.l_and",
"FStar.Sequence.Base.equal",
"Prims.op_GreaterThanOrEqual",
"FStar.Sequence.Base.contains",
"Prims.l_Exists",
"FStar.Sequence.Base.build",
"Prims.l_or",
"Prims.l_not",
"FStar.Sequence.Base.update",
"Prims.op_disEquality",
"FStar.Sequence.Base.singleton",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let test6 () : Lemma (True) =
| assert (forall (ty: Type). {:pattern empty #ty} length (empty #ty) = 0);
assert (forall (ty: Type) (s: seq ty). {:pattern length s} length s = 0 ==> s == empty);
assert (forall (ty: Type) (v: ty). {:pattern length (singleton v)} length (singleton v) = 1);
assert (forall (ty: Type) (s: seq ty) (v: ty). {:pattern build s v}
length (build s v) = 1 + length s);
assert (forall (ty: Type) (s0: seq ty) (s1: seq ty). {:pattern length (append s0 s1)}
length (append s0 s1) = length s0 + length s1);
assert (forall (ty: Type) (s: seq ty) (i: nat{i < length s}) (v: ty).
{:pattern length (update s i v)}
length (update s i v) = length s);
assert (forall (ty: Type)
(s: seq ty)
(i: nat{i < length s})
(v: ty)
(n: nat{n < length (update s i v)}).
{:pattern index (update s i v) n}
n < length s ==>
(i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n));
assert (forall (ty: Type) (s: seq ty) (x: ty). {:pattern contains s x}
contains s x <==> (exists (i: nat). {:pattern index s i} i < length s /\ index s i == x));
assert (forall (ty: Type) (x: ty). {:pattern contains empty x} ~(contains empty x));
assert (forall (ty: Type) (s: seq ty) (v: ty) (x: ty). {:pattern contains (build s v) x}
contains (build s v) x <==> (v == x \/ contains s x));
assert (forall (ty: Type) (s: seq ty) (n: nat{n <= length s}) (x: ty).
{:pattern contains (take s n) x}
contains (take s n) x <==>
(exists (i: nat). {:pattern index s i} i < n /\ i < length s /\ index s i == x));
assert (forall (ty: Type) (s: seq ty) (n: nat{n <= length s}) (x: ty).
{:pattern contains (drop s n) x}
contains (drop s n) x <==>
(exists (i: nat). {:pattern index s i} n <= i && i < length s /\ index s i == x));
assert (forall (ty: Type) (s0: seq ty) (s1: seq ty). {:pattern equal s0 s1}
equal s0 s1 <==>
length s0 == length s1 /\
(forall j. {:pattern index s0 j\/index s1 j}
0 <= j && j < length s0 ==> index s0 j == index s1 j));
assert (forall (ty: Type) (a: seq ty) (b: seq ty). {:pattern equal a b} equal a b ==> a == b);
assert (forall (ty: Type) (s0: seq ty) (s1: seq ty). {:pattern is_prefix s0 s1}
is_prefix s0 s1 <==>
length s0 <= length s1 /\
(forall (j: nat). {:pattern index s0 j\/index s1 j} j < length s0 ==> index s0 j == index s1 j
));
assert (forall (ty: Type) (s: seq ty) (n: nat). {:pattern length (take s n)}
n <= length s ==> length (take s n) = n);
assert (forall (ty: Type) (s: seq ty) (n: nat). {:pattern length (drop s n)}
n <= length s ==> length (drop s n) = length s - n);
assert (forall (ty: Type) (v: ty). {:pattern rank v} rank v == v);
assert (forall (ty: Type) (s: seq ty) (i: nat). {:pattern rank (index s i)}
i < length s ==> rank (index s i) << rank s);
assert (forall (ty: Type) (s: seq ty) (i: nat). {:pattern rank (drop s i)}
0 < i && i <= length s ==> rank (drop s i) << rank s);
assert (forall (ty: Type) (s: seq ty) (i: nat). {:pattern length (take s i)}
i < length s ==> length (take s i) << length s);
assert (forall (ty: Type) (s: seq ty) (i: nat) (j: nat).
{:pattern length (append (take s i) (drop s j))}
i < j && j <= length s ==> length (append (take s i) (drop s j)) << length s);
assert (forall (ty: Type) (s: seq ty) (n: nat). {:pattern drop s n} n = 0 ==> drop s n == s);
assert (forall (ty: Type) (s: seq ty) (n: nat). {:pattern take s n} n = 0 ==> take s n == empty);
assert (forall (ty: Type) (s: seq ty) (m: nat) (n: nat). {:pattern drop (drop s m) n}
m + n <= length s ==> drop (drop s m) n == drop s (m + n)) | false |
Vale.PPC64LE.InsBasic.fsti | Vale.PPC64LE.InsBasic.vale_stack | val vale_stack : Type0 | let vale_stack = Vale.PPC64LE.Stack_i.vale_stack | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 9,
"start_col": 7,
"start_line": 9
} | module Vale.PPC64LE.InsBasic
open FStar.Mul
open Vale.Arch.Types
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.InsBasic.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": 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": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Stack_i.vale_stack"
] | [] | false | false | false | true | true | let vale_stack =
| Vale.PPC64LE.Stack_i.vale_stack | false |
|
Vale.PPC64LE.InsBasic.fsti | Vale.PPC64LE.InsBasic.va_wp_LoadImm64 | val va_wp_LoadImm64
(dst: va_operand_reg_opr)
(src: simm16)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_LoadImm64
(dst: va_operand_reg_opr)
(src: simm16)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_LoadImm64 (dst:va_operand_reg_opr) (src:simm16) (va_s0:va_state) (va_k:(va_state -> unit
-> Type0)) : Type0 =
(va_is_dst_reg_opr dst va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_reg_opr) . let
va_sM = va_upd_operand_reg_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ va_eval_reg_opr va_sM
dst == src `op_Modulus` pow2_64 ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.PPC64LE.InsBasic.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 57,
"end_line": 61,
"start_col": 0,
"start_line": 57
} | module Vale.PPC64LE.InsBasic
open FStar.Mul
open Vale.Arch.Types
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
unfold let vale_heap = Vale.PPC64LE.Memory.vale_heap
unfold let vale_stack = Vale.PPC64LE.Stack_i.vale_stack
//-- Move
val va_code_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_code
val va_codegen_success_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> Tot va_pbool
val va_lemma_Move : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr ->
src:va_operand_reg_opr
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Move dst src) va_s0 /\ va_is_dst_reg_opr dst va_s0 /\
va_is_src_reg_opr src va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_reg_opr va_sM dst == va_eval_reg_opr va_s0 src /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_reg_opr dst va_sM va_s0))))
[@ va_qattr]
let va_wp_Move (dst:va_operand_reg_opr) (src:va_operand_reg_opr) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_is_dst_reg_opr dst va_s0 /\ va_is_src_reg_opr src va_s0 /\ va_get_ok va_s0 /\ (forall
(va_x_dst:va_value_reg_opr) . let va_sM = va_upd_operand_reg_opr dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_reg_opr va_sM dst == va_eval_reg_opr va_s0 src ==> va_k va_sM (())))
val va_wpProof_Move : dst:va_operand_reg_opr -> src:va_operand_reg_opr -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Move dst src va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Move dst src) ([va_mod_reg_opr dst])
va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Move (dst:va_operand_reg_opr) (src:va_operand_reg_opr) : (va_quickCode unit
(va_code_Move dst src)) =
(va_QProc (va_code_Move dst src) ([va_mod_reg_opr dst]) (va_wp_Move dst src) (va_wpProof_Move dst
src))
//--
//-- LoadImm64
val va_code_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_code
val va_codegen_success_LoadImm64 : dst:va_operand_reg_opr -> src:simm16 -> Tot va_pbool
val va_lemma_LoadImm64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr -> src:simm16
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_LoadImm64 dst src) va_s0 /\ va_is_dst_reg_opr dst
va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_reg_opr va_sM dst == src `op_Modulus` pow2_64 /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_reg_opr dst va_sM va_s0)))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.InsBasic.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": 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": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
dst: Vale.PPC64LE.Decls.va_operand_reg_opr ->
src: Vale.PPC64LE.Machine_s.simm16 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Decls.va_operand_reg_opr",
"Vale.PPC64LE.Machine_s.simm16",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.PPC64LE.Decls.va_is_dst_reg_opr",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.l_Forall",
"Vale.PPC64LE.Decls.va_value_reg_opr",
"Prims.l_imp",
"Prims.eq2",
"Prims.int",
"Vale.PPC64LE.Decls.va_eval_reg_opr",
"Prims.op_Modulus",
"Vale.PPC64LE.Machine_s.pow2_64",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_operand_reg_opr"
] | [] | false | false | false | true | true | let va_wp_LoadImm64
(dst: va_operand_reg_opr)
(src: simm16)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_is_dst_reg_opr dst va_s0 /\ va_get_ok va_s0 /\
(forall (va_x_dst: va_value_reg_opr).
let va_sM = va_upd_operand_reg_opr dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_reg_opr va_sM dst == src `op_Modulus` pow2_64 ==> va_k va_sM (()))) | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.